Skip to content
Sharp

Object-oriented programming · interview question

How do unmodifiable views differ from defensive copies in protecting internal collections?

Multiple choiceMediumchapter-3-curatedpremiumoopdefensive-copying
Choose one answer
Answer and explanation

Correct answer

C. Unmodifiable views prevent modification without creating a new copy

Why

Unmodifiable views provide a view of the collection that prevents modifications without creating a new copy, whereas defensive copies create a separate instance that can be modified without affecting the original.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →