Courseiva
Java Basics and SyntaxhardMultiple ChoiceObjective-mapped

1Z0-811 Java Basics and Syntax Practice Question

Given method: static void change(String s) { s = "new"; } What is output of: String name = "original"; change(name); System.out.println(name);

⚠ Common exam trap

The trap here is that candidates mistakenly think Java passes objects by reference, leading them to believe the method's reassignment changes the original variable, when in fact only the local reference is modified.

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

"original"

Java passes object references by value. Inside the method `change`, the local variable `s` is reassigned to a new String object, but this does not affect the original reference `name` in the main method. Strings are immutable, so the original `name` remains "original".

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • null

    Why it's wrong here

    Incorrect. name was never set to null.

  • "new"

    Why it's wrong here

    Incorrect. The method does not change the original reference.

  • "original"

    Why this is correct

    Correct. name still refers to "original".

  • Compilation error

    Why it's wrong here

    Incorrect. Code compiles and runs.

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 →

How Courseiva writes practice questions · Editorial policy

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.