Question
Which statement about Immutable Class Design is the strongest interview answer?
- Immutable Class Design is mostly a naming style choice and has little effect on runtime or design.
- An immutable class never allows its externally visible state to change after construction.
- Immutable Class Design exists mainly to reduce the number of Java files in a project.
- Immutable Class Design matters only for frontend frameworks, not for core Java applications.
Hint
Start with the core rule behind Immutable Class Design.
Answer and rationale
Correct answer: B. An immutable class never allows its externally visible state to change after construction.
An immutable class never allows its externally visible state to change after construction. This is the base concept interviewers commonly test first.
Track: Java