Bird
0
0

Given nested loops labeled outer and inner, how can you skip only the current iteration of the outer loop when a condition in the inner loop is met?

hard📝 Application Q15 of 15
Kotlin - Loops and Ranges
Given nested loops labeled outer and inner, how can you skip only the current iteration of the outer loop when a condition in the inner loop is met?
AUse <code>break@outer</code> inside inner loop.
BUse <code>continue</code> without label inside inner loop.
CUse <code>continue@outer</code> inside inner loop.
DUse <code>break</code> without label inside inner loop.
Step-by-Step Solution
Solution:
  1. Step 1: Understand labeled continue effect

    Using continue@outer skips the current iteration of the outer loop, moving to the next iteration of outer.
  2. Step 2: Compare with break and unlabeled continue

    break@outer would exit the outer loop entirely, not just skip iteration. Unlabeled continue affects only inner loop.
  3. Final Answer:

    Use continue@outer inside inner loop. -> Option C
  4. Quick Check:

    continue@outer skips outer loop iteration [OK]
Quick Trick: Use continue@label to skip labeled loop iteration [OK]
Common Mistakes:
MISTAKES
  • Using break@outer instead of continue@outer
  • Using unlabeled continue to skip outer loop
  • Confusing break and continue effects

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes