Share on Google+Share on Google+

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.

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




Posted on: July 13, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial 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.


Advertisement null