ProgrammingHardAmazon/Microsoft SDE MCQ · Java placement

What is printed?

What is printed?
outer:
for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
        if (j == i) continue outer;
        if (i + j == 3) break outer;
        System.out.print(i + "" + j + " ");
    }
}
  1. A. 10 20
  2. B. 10 20 21
  3. C. 10
  4. D. 01 10 20

Correct answer: A. 10 20

i = 0: j = 0 equals i, so continue outer. i = 1: prints 10, then j = 1 continues outer. i = 2: prints 20, then j = 1 gives i + j = 3 and breaks out of both loops.

More OOP with C++ and Java questions

Exams that ask this topic