1Z0-811 Primitives, Strings and Operators Practice Question
Which TWO of the following operations on String objects result in a new String object?
⚠ Common exam trap
Oracle often tests the distinction between methods that return a new `String` versus those that return a primitive or the same reference, exploiting the common misconception that all `String` methods modify the original object.
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
✓
"Hello".replace('l', 'p')
`String.replace()` returns a new `String` object with the replacement applied, as `String` is immutable in Java. The original `"Hello"` remains unchanged, and a new string `"Heppo"` is created.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
"Hello".toString()
Why it's wrong here
Returns the same string object (this).
- ✗
"Hello".length()
Why it's wrong here
Returns int.
- ✗
"Hello".charAt(0)
Why it's wrong here
Returns a primitive char.
- ✓
"Hello".replace('l', 'p')
Why this is correct
Returns new string with replacements.
- ✓
"Hello".concat(" World")
Why this is correct
Returns a new concatenated string.
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.