Bird
0
0

Why does Kotlin require labels with break and continue when used in nested loops?

hard📝 Conceptual Q10 of 15
Kotlin - Loops and Ranges
Why does Kotlin require labels with break and continue when used in nested loops?
ATo specify which loop to break or continue when multiple loops are nested
BTo improve performance of loops
CTo declare variables inside loops
DTo enable recursion inside loops
Step-by-Step Solution
Solution:
  1. Step 1: Understand nested loop control flow

    Without labels, break or continue affect only the innermost loop.
  2. Step 2: Purpose of labels in nested loops

    Labels let you specify which loop to break or continue, avoiding ambiguity.
  3. Final Answer:

    To specify which loop to break or continue when multiple loops are nested -> Option A
  4. Quick Check:

    Labels clarify loop control in nested loops [OK]
Quick Trick: Labels clarify which loop break/continue affects [OK]
Common Mistakes:
MISTAKES
  • Thinking labels improve performance
  • Confusing labels with variable declarations
  • Assuming labels enable recursion

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes