|
|
350 Mock Questions on SCJP 1.5 - JUST Rs.200 or 7 USD
Send us mail to sales@javabeat.net
more details
|
Do you have paypal account? Click Here to pay now and get the questions.
|
|
Boxing Conversions - 2 (10 Questions)
3) What will be the output of the following program?
package wrapper_boxing;
public class WrapperTest2 {
public static void main(String[] args) {
Boolean bool1 = new Boolean(true);
Boolean bool2 = new Boolean(false);
Boolean bool3 = new Boolean("false");
Boolean bool4 = new Boolean(bool1);
System.out.println(bool1.equals(bool4));
System.out.println(bool2 == bool3);
System.out.println(bool1 == bool4);
}
}
- The program will not compile because the creation of bool4 object will cause compilation error.
- The program will produce the output 'true false false'.
- The program will produce the output 'true true true'.
- The program will output 'true false true'.
Answer
3)2
The first comparison statement compares the value of two objects and hence will return true. Whereas the second and the third comparison verfires whether the references are pointing to the same object, in which case both the comparisons will fail.
|
|
350 Mock Questions on SCJP 1.5 - JUST Rs.200 or 7 USD
Send us mail to sales@javabeat.net
more details
|
|