1.

What will be the output of the program (in jdk1.6 or above)?

public class BoolTest { public static void main(String [] args) { Boolean b1 = new Boolean("false"); boolean b2; b2 = b1.booleanValue(); if (!b2) { b2 = true; System.out.print("x "); } if (b1 & b2) /* Line 13 */ { System.out.print("y "); } System.out.println("z"); }
}

A. z
B. x z
C. <!--<p> Answer:The compiler fails at line 13 because b1 is a reference variable to a <i class="java-code">Boolean</i> wrapper object, not a boolean primitive. Logical boolean tests can't be made on <i class="java-code">Boolean</i> objects.</p> -->
D. y z
E. Compilation fails.
Answer» C. <!--<p> Answer:The compiler fails at line 13 because b1 is a reference variable to a <i class="java-code">Boolean</i> wrapper object, not a boolean primitive. Logical boolean tests can't be made on <i class="java-code">Boolean</i> objects.</p> -->


Discussion

No Comment Found

Related MCQs