Skip to content
Sharp

Modern Java · interview question

How can the use of enums improve the clarity of domain models in Java?

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

Correct answer

B. By clearly representing a fixed set of constants.

Why

Enums are used to represent a fixed set of constants, improving code readability and reducing errors by preventing invalid values. They enhance code clarity by providing a clear, type-safe way to manage constant values.

Test yourself on Modern Java

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

Start free test
All Modern Java questions →