Skip to content
Sharp

Modern Java · interview question

Which keyword is used in a switch expression to handle control flow and return values without fall-through?

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

Correct answer

B. Yield

Why

The 'yield' keyword in switch expressions is used to return a value from a case block, ensuring no fall-through and providing a clear mechanism for producing results.

Test yourself on Modern Java

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

Start free test
All Modern Java questions →