Skip to content
Sharp

Object-oriented programming · interview question

How does making a class immutable help reduce mutation bugs in an e-commerce application?

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

Correct answer

B. Immutable objects do not change state, reducing unintended side effects.

Why

Immutable objects cannot change state after creation, which prevents unintended side effects from occurring when objects are shared across different parts of the application. This reduces mutation-related bugs, especially in concurrent environments.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →