1Z0-811 Control Flow and Loops Practice Question
A developer writes the following code: for (int i = 0; i < 5; i++) { for (int j = i; j < 5; j++) { System.out.print(j); } } How many times does the inner loop execute in total?
⚠ Common exam trap
Oracle often tests the misconception that the inner loop runs a fixed number of times (like 5) per outer iteration, leading candidates to multiply 5*5=25 or mis-sum the decreasing counts.
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
✓
15
The outer loop runs with i from 0 to 4 (5 iterations). For each i, the inner loop runs from j = i to j < 5, so the number of inner iterations is 5 - i. Summing these: 5 + 4 + 3 + 2 + 1 = 15. Thus, the inner loop executes 15 times in total.
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 it's wrong here
That is the number of outer loop iterations.
- ✓
15
Why this is correct
Sum from 5 down to 1 equals 15.
- ✗
10
Why it's wrong here
Not the correct sum.
- ✗
20
Why it's wrong here
Would be true if inner loop always ran 5 times.
Go deeper
Related to this question
About these practice questions
This 1Z0-811 question is part of Courseiva's 481-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. 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-811 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-811 exam.