Skip to content
CodeKruPro

Labelled break and continue in nested loops

QuizMediumJava onlyAsked in: TCS, Wipro

What does this print?

outer:
for (int r = 1; r <= 3; r++) {
    for (int c = 1; c <= 3; c++) {
        if (c == 2) continue outer;
        if (r == 3) break outer;
        System.out.print(r + "" + c + " ");
    }
}
  • 11 21
  • 11 21 31
  • 11 13 21 23
  • 11

This question is part of Pro+

Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.

See Pro+

Already have Pro+? Sign in