Bird
0
0

What does the step keyword do in a Kotlin for loop?

easy📝 Conceptual Q1 of 15
Kotlin - Loops and Ranges
What does the step keyword do in a Kotlin for loop?
AIt sets the starting value of the loop variable.
BIt defines the increment or decrement value for each loop iteration.
CIt reverses the order of the loop.
DIt terminates the loop early.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the role of step in loops

    The step keyword controls how much the loop variable changes after each iteration.
  2. Step 2: Identify what step affects

    It changes the increment or decrement value, allowing skipping numbers or stepping backwards.
  3. Final Answer:

    It defines the increment or decrement value for each loop iteration. -> Option B
  4. Quick Check:

    step keyword = increment/decrement value [OK]
Quick Trick: Use step to skip numbers or reverse steps easily [OK]
Common Mistakes:
MISTAKES
  • Thinking step reverses the loop
  • Confusing step with loop start
  • Assuming step ends the loop

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes