Unit 2 Cycle 2 Day 13: Iteration (break)
Share
Unit 2, Selection & Iteration • Cycle 2
Day 13 Advanced Practice • Harder Difficulty
Focus: Break Statement
Hard
Iteration (break)
Advanced Practice Question
Format: Iteration (break)
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">4)
{
break;
}
sum += i;
}
System.out.println(sum);
Difficulty: Hard |
Topic: Iteration (break) |
Cycle: 2 (Advanced)
Why This Answer?
The loop adds 1 + 2 + 3, then breaks when i reaches 4. Sum is 6.
Common Mistake
Watch Out!
Thinking 4 is included even though `break` happens before `sum += i`.
AP Exam Strategy
When you see `break`, check whether it happens before or after the work inside the loop.
Master This Topic
This Cycle 2 HARD question tests break statement. Review Unit 2 concepts to build mastery of selection and iteration.
- Understanding break 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