Home Tutorial Java Scjp Part7 SCJP Module-7 Question-1


Share on Google+Share on Google+
SCJP Module-7 Question-1
Posted on: July 13, 2010 at 12:00 AM
The Sample program given below will test your understanding about the Boolean class in Java and helpful for SCJP examination.

Given a sample code:

1    public class Test {
2    public static void main(String[] args) {
3    Boolean b1 = new Boolean(true);
4    String s1 = new String("abc");
5    String s2 = new String("abc");
6    Boolean b4 = new Boolean(b1);
7    System.out.print(b1.equals(b4) + " ");
8    System.out.print((s1 == s2) + " ");
9    System.out.print(b1 == b4);

What will be the result of above code ?

(1) The program compilation fails because of line number 6.
(2) true false false
(3) false false true
(4) true true false



Related Tags for SCJP Module-7 Question-1:

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 13, 2010

Recommend the tutorial

Advertisements Advertisements