1Z0-811 Primitives, Strings and Operators Practice Question
Given: int a = 10; int b = 20; boolean flag = a++ > 10 && ++b > 20; What are the values of a and b after execution?
⚠ Common exam trap
The trap here is that candidates often forget that post-increment `a++` uses the original value for the comparison but still increments `a` afterward, and they also overlook short-circuit evaluation, assuming both sides of `&&` are always evaluated.
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=11, b=20
The expression `a++ > 10 && ++b > 20` uses short-circuit evaluation. Since `a++` is post-increment, the comparison uses the original value of `a` (10) before incrementing, so `10 > 10` is false. Because the left operand is false, the `&&` operator short-circuits and the right operand `++b > 20` is never evaluated. Therefore, `a` is incremented to 11, but `b` remains 20, making option D 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.
- ✗
a=10, b=21
Why it's wrong here
Incorrect: a is incremented to 11, and b is not incremented.
- ✗
a=10, b=20
Why it's wrong here
Incorrect: a is incremented to 11 due to post-increment.
- ✗
a=11, b=21
Why it's wrong here
Incorrect: due to short-circuit, b is not incremented.
- ✓
a=11, b=20
Why this is correct
Correct: a becomes 11, b remains 20 because the right side of && is not evaluated.
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.