Skip to content
Sharp

Software Architecture · interview question

When designing an immutable class using the Builder pattern, what is a crucial step to ensure immutability?

Multiple choiceHardchapter-13-curatedpremiumsoftware-architecturebuilder-pattern
Choose one answer
Answer and explanation

Correct answer

B. Ensure all fields are final and private.

Why

To ensure immutability, all fields of the class should be declared as final and private. This prevents changes to the fields after the object is constructed, ensuring the object's state cannot be altered.

Test yourself on Software Architecture

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

Start free test
All Software Architecture questions →