Courseiva
Controlling Program FloweasyMultiple ChoiceObjective-mapped

1Z0-829 Controlling Program Flow Practice Question

Exhibit

Refer to the exhibit.

```
int count = 0;
for (int i = 0; i < 5; i++) {
    if (i == 3) {
        break;
    }
    count++;
}
System.out.println(count);
```

What is the output?

⚠ Common exam trap

The trap here is that candidates often miscount the number of iterations by including the value where the condition becomes false, leading to an off-by-one error, or they confuse the loop's upper bound (3) with the number of iterations.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

3

3 because the code uses a `for` loop that increments `i` from 0 to 4, but the loop body only executes when `i < 3` due to the condition `i < 3`. The loop runs for `i = 0, 1, 2` (three iterations), and each time `count` is incremented by 1, resulting in `count = 3`. The final value of `count` is printed.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • 3

    Why this is correct

    Loop runs for i=0,1,2 then breaks.

  • 0

    Why it's wrong here

    count is incremented.

  • 4

    Why it's wrong here

    Break at i=3 prevents increment.

  • 5

    Why it's wrong here

    Loop exits early.

About these practice questions

One of 513 original 1Z0-829 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This 1Z0-829 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-829 exam.