Skip to content
Sharp

Object-oriented programming · interview question

Why is immutability a desirable property for objects representing value-like data, such as a customer's profile?

Multiple choiceMediumchapter-3-curatedpremiumoopimmutability-basics
Choose one answer
Answer and explanation

Correct answer

D. It prevents accidental modification, reducing bugs.

Why

Immutability ensures that an object's state cannot be modified after construction, which helps prevent bugs related to unintended changes and makes the object easier to reason about.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →