Courseiva
Controlling Program FloweasyMultiple ChoiceObjective-mapped

1Z0-829 Controlling Program Flow Practice Question

Given: for(int i=0; i<3; i++) { for(int j=0; j<3; j++) { if(i==1 && j==1) break; } } What is the value of i after the outer loop completes?

⚠ Common exam trap

The trap here is that candidates often mistakenly think `break` exits all nested loops or that the loop variable retains the value at the time of the break, leading them to choose 1 or 2 instead of recognizing the outer loop continues to completion.

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 outer loop variable `i` increments from 0 to 2. When `i` is 1 and `j` is 1, the `break` statement exits only the inner `for` loop, not the outer loop. The outer loop continues to its next iteration, incrementing `i` to 2, then to 3. When `i` becomes 3, the outer loop condition `i < 3` fails, so the loop terminates. Thus, after the outer loop completes, `i` 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.

  • 1

    Why it's wrong here

    Incorrect; the outer loop does not stop at i=1.

  • 2

    Why it's wrong here

    Incorrect; the outer loop continues to i=3.

  • 4

    Why it's wrong here

    Incorrect; i never reaches 4 because the loop condition i<3 stops at i=3.

  • 3

    Why this is correct

    Correct: the outer loop completes all three iterations, ending with i=3.

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.