1Z0-811 Primitives, Strings and Operators Practice Question
A developer writes: String s = "Hello"; s.concat(" World"); System.out.println(s); What is the output?
⚠ Common exam trap
The trap here is that candidates often forget that strings are immutable and assume methods like `concat()` modify the original object, leading them to choose "Hello World" instead of "Hello".
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
Strings in Java are immutable. The `concat()` method returns a new string but does not modify the original string `s`. Since the return value is not assigned to any variable, the original string `s` remains unchanged, so `System.out.println(s)` prints "Hello".
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 fails
Why it's wrong here
Incorrect because code compiles.
- ✗
Hello World
Why it's wrong here
Incorrect because concat result is not assigned.
- ✓
Hello
Why this is correct
Correct because concat does not modify s.
- ✗
Hello World
Why it's wrong here
Incorrect, same as A.
Go deeper
Related to this question
About these practice questions
Courseiva writes every 1Z0-811 question from scratch — 481 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-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.