1Z0-829 Controlling Program Flow Practice Question
Given: int x=0; do { x++; } while(x<5); How many times does the loop body execute?
⚠ Common exam trap
The trap here is that candidates often miscount by forgetting the do-while loop executes the body before checking the condition, leading them to think the loop runs only 4 times (confusing it with a standard while loop) or 6 times (misapplying the condition threshold).
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
✓
5
The do-while loop executes the body first, then checks the condition. The variable x starts at 0, so initially the body executes with x=0, then x increments to 1. The loop continues as long as x < 5. The body executes for x = 0, 1, 2, 3, 4 — a total of 5 times. When x becomes 5, the condition x < 5 is false, so the loop stops.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
5
Why this is correct
Correct: runs for x=0 through 4, inclusive.
- ✗
4
Why it's wrong here
Incorrect; it runs 5 times.
- ✗
6
Why it's wrong here
Incorrect; the condition stops at 5.
- ✗
0
Why it's wrong here
Incorrect; do-while always executes at least once.
Go deeper
Related to this question
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 →
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.