Unit 2 Cycle 2 Day 21: Iteration (break)

Unit 2, Selection & Iteration • Cycle 2
Day 21 Advanced Practice • Harder Difficulty
Focus: Early Exit Hard Iteration (break)

Advanced Practice Question

Format: Iteration (break)

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)
    {
        break;
    }

    sum += i;
}

System.out.println(sum);
Difficulty: Hard  |  Topic: Iteration (break)  |  Cycle: 2 (Advanced)
Why This Answer?

The loop adds 1 and 2, then breaks when i is 3. Sum is 3.

Common Mistake
Watch Out!

Including 3 even though the break occurs before the addition.

AP Exam Strategy

When break triggers, the loop stops immediately—no further statements run in that iteration.

Master This Topic

This Cycle 2 HARD question tests early exit. Review Unit 2 concepts to build mastery of selection and iteration.

  • Understanding early exit
  • Tracing code execution accurately
  • Avoiding common pitfalls
View Unit 2 Study Guide

Ready for More Challenges?

Cycle 2 questions prepare you for the hardest AP CSA exam questions.

Study Games Practice FRQs
Back to blog

Leave a comment

Please note, comments need to be approved before they are published.