Courseiva
Question 156 of 513
Controlling Program FlowmediumMultiple ChoiceObjective-mapped

1Z0-829 Loop iteration count Practice Question

Exhibit

Refer to the exhibit.

public class LoopTest {
    public static void main(String[] args) {
        int count = 0;
        OUTER: for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (i == 1 && j == 1) {
                    break OUTER;
                }
                count++;
            }
        }
        System.out.println(count);
    }
}

Given the following code fragment: ```java

int x = 0;
for (int i = 0; i < 4; i++) {

x++;

}

System.out.println(x); ``` What is the result?

⚠ Common exam trap

Without the code, the answer is arbitrary. In a real exam, carefully examine the loop condition, initial value, and increment to avoid off-by-one errors. Here, if a loop runs for 4 iterations, the result is 4.

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

4

The loop runs four times (i = 0, 1, 2, 3), incrementing x each time. Therefore, x becomes 4, so the output is 4. Option B is correct.

Answer analysis

Option-by-option breakdown

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

  • 9

    Why it's wrong here

    9 is incorrect; likely from a different loop or a different construct.

  • 4

    Why this is correct

    4 is correct as the loop runs 4 times.

  • 3

    Why it's wrong here

    3 might be chosen if condition was i<3 or if starting at i=1.

  • 5

    Why it's wrong here

    5 might be chosen if condition was i<=4 or if starting at i=1 with condition i<5.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Last reviewed: Jun 11, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

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.