Question 1
Which two statements about switch in Java are correct? (Choose two.)
A. In a switch statement with colon labels, control falls through to the next label unless a break (or other jump) intervenesCorrect answer
Correct: colon labels in a switch statement fall through, so after a matching label runs execution continues into subsequent labels until a `break` (or another jump such as `return`) intervenes.
B. A switch statement over an enum must cover every enum constant or provide a default, otherwise it does not compile
Only a switch expression must be exhaustive; a switch statement over an enum may omit constants and simply do nothing for unlisted values, so it still compiles and runs.
C. The default label may be written before the case labels in a switch blockCorrect answer
Correct: the `default` label is not required to be last; it may be placed before, between, or after the `case` labels, and its position does not change which label the selector matches.
D. return may be used inside an arm of a switch expression to make that value the result of the switch
A switch expression produces its value only via `yield` (or an arrow expression); a `return` that leaves the switch expression is a compile error.
Explanation
Fall-through and tolerance of uncovered values are properties of the colon statement form, while exhaustiveness and no-fall-through belong to the expression and arrow forms. The `default` label may appear anywhere in the block, not only last, without changing which label the selector matches. A switch expression yields its value rather than returning it, so any `return` leaving the expression is a compile error.