Multiple choice technology programming languages

public static void main(String [] args) { int x = 5; boolean b1 = true; boolean b2 = false; if ((x == 4) && !b2 ) System.out.print("1"); System.out.print("2"); if ((b2 = true) && b1 ) System.out.print("3"); } } What is the result?

  1. 2

  2. 2 3

  3. 1 2 3

  4. Compilation fails

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

The first if-condition (x == 4) && !b2 evaluates to false because x is 5, so '1' is not printed. Next, '2' is printed unconditionally. The second if-condition (b2 = true) && b1 assigns true to b2, making the expression true && true, which evaluates to true, so '3' is printed.