Skip to content
Sharp

Object-oriented programming · interview question

Which approach ensures that a method in Java returns a deep copy of an object?

Multiple choiceHardchapter-3-curatedpremiumoopobject-responsibility
Choose one answer
Answer and explanation

Correct answer

A. Returning a new instance with copied fields

Why

Returning a new instance with copied fields ensures a deep copy, meaning changes to the original object do not affect the copy. This approach maintains object integrity and independence.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →