Multiple choice technology programming languages

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); } }

  1. The program will not compile because the creation of bool4 object will cause compilation error.

  2. The program will produce the output 'true false false'.

  3. The program will produce the output 'true true true'.

  4. The program will output 'true false true'.

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

bool1.equals(bool4) returns true because both contain value 'true'. bool2 == bool3 returns false because they are different object references. bool1 == bool4 returns false because 'new' creates separate objects.