Skip to content
Sharp

Object-oriented programming · interview question

When designing a class for an e-commerce application, under which condition would you choose to make it immutable?

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

Correct answer

C. If the class represents a customer's order history.

Why

An immutable class is ideal for representing data that does not change once created, such as a customer's order history. This ensures consistency and thread safety.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →