ProgrammingHardTCS NQT Prime · Infosys SP

What is printed?

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

Correct answer: A. 00,10,

Each i prints only j=0 because j==1 continues the outer loop; at i=2, j=0 triggers break outer before printing.

More OOP with C++ and Java questions

Exams that ask this topic