1Z0-811 Primitives, Strings and Operators Practice Question
What is the result of the following code? Integer a = 100; Integer b = 100; System.out.println(a == b);
⚠ Common exam trap
Oracle often tests the Integer cache behavior by using values within the cached range (like 100) to trick candidates who assume that == always compares references and would be false for Integer objects.
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
✓
true
Java caches Integer objects for values between -128 and 127. When autoboxing converts the int literal 100 to an Integer object, both a and b reference the same cached object. Therefore, the == operator, which compares object references, returns true.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
true
Why this is correct
Correct: both refer to same cached Integer object.
- ✗
false
Why it's wrong here
False would be for values outside cache range, e.g., 200.
- ✗
Compilation error
Why it's wrong here
Code compiles fine.
- ✗
Runtime exception
Why it's wrong here
No exception thrown.
Go deeper
Related to this question
About these practice questions
One of 481 original 1Z0-811 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-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.