SCJP Module-7 Question-1


 

SCJP Module-7 Question-1

The Sample program given below will test your understanding about the Boolean class in Java and helpful for SCJP examination.

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

Answer:

(2)

Ads