1Z0-811 Java Basics and Syntax Practice Question
Given two String objects s1 = "Hello" and s2 = "Hello", what does the expression (s1 == s2) return?
⚠ Common exam trap
Many exam-takers confuse reference equality (`==`) with value equality (`.equals()`), and incorrectly assume `==` always returns `false` for strings, forgetting that string literals are interned.
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
The `==` operator compares object references, not string content. Since both `s1` and `s2` are string literals, Java's string interning ensures they refer to the same `String` object in the string constant pool, so `s1 == s2` 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.
- ✗
Compilation error
Why it's wrong here
== can be used with object references.
- ✗
false
Why it's wrong here
Because of interning, both references point to the same object.
- ✗
It depends on the JVM
Why it's wrong here
Interning is guaranteed for string literals.
- ✓
true
Why this is correct
Both strings are string literals, so they are interned and share the same reference.
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.