1Z0-829 Controlling Program Flow Practice Question
Given the code snippet:
int x = 10;
if (x > 5) {System.out.print("A");
} else if (x > 7) {System.out.print("B");
} else {System.out.print("C");
}
What is the output?
⚠ Common exam trap
The trap here is that candidates mistakenly think the else if condition (x > 7) is also true and will execute, or that all branches are evaluated sequentially, leading them to choose 'ABC' or 'B' instead of recognizing the exclusive nature of if-else-if.
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
✓
A
The if-else chain evaluates conditions sequentially. Since x=10 satisfies x > 5, the first block executes and prints 'A'. The else if and else branches are skipped entirely because the first condition was true. Thus, only 'A' is output.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
C
Why it's wrong here
The else is skipped.
- ✗
ABC
Why it's wrong here
Only one branch executes.
- ✓
A
Why this is correct
The first condition is true.
- ✗
B
Why it's wrong here
The else if is skipped.
Go deeper
Related to this question
About these practice questions
Courseiva writes every 1Z0-829 question from scratch — 513 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or 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-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.