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

 
 

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

Answer:

(2)

Related Tags for SCJP Module-7 Question-1:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.