Given this code fragment:
What is the outcome?
A Java switch expression must be exhaustive. These labels cover only the integer values 1 through 6; because there is no default label to handle all other int values, the code produces a compile-time error.
switch
default
int
Community Discussion