Skip to content
Sharp

Modern Java · interview question

Which switch expression feature helps ensure cleaner code in Java?

Multiple choiceMediumchapter-12-curatedpremiummodern-javaswitch-expressions
Choose one answer
Answer and explanation

Correct answer

A. Exhaustiveness checks

Why

Exhaustiveness checks in switch expressions ensure that all possible input values are accounted for, either by specific cases or a default case, leading to more robust and predictable code.

Test yourself on Modern Java

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

Start free test
All Modern Java questions →