Skip to content
Sharp

Core Java · interview question

Why do teams use enums over constant integer values in Java in production code?

Multiple choiceEasychapter-7-curatedpremiumcore-javacode-reading-with-modern-java
Choose one answer
Answer and explanation

Correct answer

D. Type safety

Why

Enums provide type safety, allowing the compiler to catch invalid assignments at compile time, unlike constant integer values, which can lead to errors at runtime.

Test yourself on Core Java

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

Start free test
All Core Java questions →