Skip to content
Sharp

Modern Java · interview question

Why do teams use final fields in Java domain models in production code?

Multiple choiceEasychapter-7-curatedpremiummodern-javacleaner-domain-modeling
Choose one answer
Answer and explanation

Correct answer

A. They ensure fields are initialized only once.

Why

Final fields in Java ensure that a field is initialized only once and cannot be changed afterwards, which enhances the immutability of domain models and ensures consistent state once the object is constructed.

Test yourself on Modern Java

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

Start free test
All Modern Java questions →