Multiple choice technology programming languages

What happens when the following code is compiled and run. Select the one correct answer. for(int i = 2; i < 4; i++) for(int j = 2; j < 4; j++) if(i < j) assert i!=j : i;

  1. The class compiles and runs, but does not print anything.

  2. The number 2 gets printed with AssertionError

  3. compile error

  4. The number 3 gets printed with AssertionError

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

The nested loops iterate i=2,3 and j=2,3. The condition if(i < j) filters cases: (2,3) and (2,3) where assert i!=j executes. Since 2!=3 and 2!=3 are both true, the assert never fails. When the assert condition is true (i != j), no AssertionError is thrown. Thus code compiles, runs, and prints nothing.