1Z0-811 Java Basics and Syntax Practice Question
Given: String s = "Java"; s.concat(" Rocks"); System.out.println(s); What prints?
⚠ Common exam trap
The trap here is that candidates mistakenly believe `concat()` modifies the original string, confusing it with mutable classes like StringBuilder or StringBuffer, or they forget that the return value must be assigned to capture the result.
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
✓
"Java"
Strings in Java are immutable. The `concat()` method returns a new string object 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 "Java".
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
"Java"
Why this is correct
Correct. s still refers to "Java".
- ✗
"Rocks"
Why it's wrong here
Incorrect. The result of concat is ignored.
- ✗
""
Why it's wrong here
Incorrect. No operation changes s.
- ✗
"Java Rocks"
Why it's wrong here
Incorrect. concat() returns a new string; original unchanged.
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.