Bird
0
0

What happens if the condition in a while loop is false at the start?

easy📝 Conceptual Q1 of 15
Kotlin - Loops and Ranges
What happens if the condition in a while loop is false at the start?
AThe loop body does not execute at all
BThe loop body executes once
CThe loop runs infinitely
DThe program crashes
Step-by-Step Solution
Solution:
  1. Step 1: Understand while loop behavior

    A while loop checks the condition before running the loop body.
  2. Step 2: Analyze condition false at start

    If the condition is false initially, the loop body is skipped entirely.
  3. Final Answer:

    The loop body does not execute at all -> Option A
  4. Quick Check:

    While loop skips if condition false = D [OK]
Quick Trick: While loops check condition first, may skip body [OK]
Common Mistakes:
MISTAKES
  • Thinking while loop runs once regardless
  • Confusing with do-while loop
  • Assuming infinite loop if false condition

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes