Skip to content
Sharp

Object-oriented programming · interview question

In Java, what happens when you assign one object reference to another?

Multiple choiceEasychapter-2-curatedpremiumoopobject-references
Choose one answer
Answer and explanation

Correct answer

B. Both references point to the same object.

Why

In Java, when you assign one object reference to another, both variables end up pointing to the same object in memory. No new object is created.

Test yourself on Object-oriented programming

A free test with instant, explained results. No account needed.

Start free test
All Object-oriented programming questions →