Skip to content
Sharp

Modern Java · interview question

What feature of switch expressions helps prevent bugs related to missing break statements?

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

Correct answer

C. Arrow syntax with expression bodies.

Why

The arrow syntax in switch expressions replaces the need for 'break' statements, which eliminates the potential for fall-through bugs that are common in traditional switch statements. This leads to safer and more predictable control flow.

Test yourself on Modern Java

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

Start free test
All Modern Java questions →