Unit 2 Cycle 2 Day 22: Iteration (continue)
Share
Unit 2, Selection & Iteration • Cycle 2
Day 22 Advanced Practice • Harder Difficulty
Focus: Continue Statement
Hard
Iteration (continue)
Advanced Practice Question
Format: Iteration (continue)
What is printed?
What is printed?
"apcs-keyword">int sum = "apcs-number">0;
"apcs-keyword">for ("apcs-keyword">int i = "apcs-number">1; i <= "apcs-number">5; i++)
{
"apcs-keyword">if (i == "apcs-number">3)
{
continue;
}
sum += i;
}
System.out.println(sum);
Difficulty: Hard |
Topic: Iteration (continue) |
Cycle: 2 (Advanced)
Why This Answer?
When i is 3, `continue` skips `sum += i` for that iteration. The sum is 1 + 2 + 4 + 5 = 12.
Common Mistake
Watch Out!
Thinking `continue` ends the entire loop (it only skips to the next iteration).
AP Exam Strategy
`continue` skips the rest of the loop body for that iteration, then the loop continues.
Master This Topic
This Cycle 2 HARD question tests continue statement. Review Unit 2 concepts to build mastery of selection and iteration.
- Understanding continue statement
- Tracing code execution accurately
- Avoiding common pitfalls
Ready for More Challenges?
Cycle 2 questions prepare you for the hardest AP CSA exam questions.
Study Games Practice FRQs