Courseiva
Controlling Program FlowmediumMultiple ChoiceObjective-mapped

1Z0-829 Controlling Program Flow Practice Question

Exhibit

Refer to the exhibit.
public class Test {
    public static void main(String[] args) {
        int i = 0;
        while (i < 5) {
            if (i == 3) break;
            i++;
        }
        System.out.println(i);
    }
}

```java

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 loop iterations by including the iteration where `break` occurs, forgetting that `break` exits before the loop body's remaining statements (including `count++`) execute.

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

The code uses a loop that increments a variable count. It breaks when a certain condition (e.g., when a loop index equals 3) is met, after counting three iterations. Therefore, the output is 3.

Answer analysis

Option-by-option breakdown

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

  • 4

    Why it's wrong here

    Incorrect; i is not incremented after break.

  • 3

    Why this is correct

    Correct: break at i=3 prevents further increment.

  • 5

    Why it's wrong here

    Incorrect; the loop exits early.

  • Compilation error

    Why it's wrong here

    Incorrect; the code compiles.

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.