Multiple choice

What will be the output of the program? int x = 3; int y = 1; if (x = y) /* Line 3 */ { System.out.println(x = + x); }

  1. x = 1

  2. x = 3

  3. compilation fails

  4. no output

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

Line 3 uses an assignment as opposed to comparison. Because of this, the if statement receives an integer value instead of a boolean. And so the compilation fails.