Skip to content
Sharp

Object-oriented programming · interview question

What happens if you assign a 'Product' object reference in a 'Customer' object, and then set the 'Product' to null?

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

Correct answer

B. The reference in Customer remains valid unless explicitly set to null.

Why

Setting a reference to null only affects that specific reference. Other references to the object remain valid.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →