Multiple choice

What will be the output of the program?

int i = O; while(1) { if(i == 4) { break; } ++i; } System.out.println(i = + i);

  1. i = 0

  2. i = 3

  3. i = 4

  4. Compilation fails

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

Compilation fails because the argument and the condition of while loop must be of primitive type boolean. In Java, one does not represent the true state of a boolean, it is rather seen as an integer.