I thought that the default case matches every expression, isn't this correct?
But on the SCJP mock exam, a question occured something like this:
I know that it is not allowed to use two expressions with case 3 in a single switch statement, but I thought "default" will match the "3" expression (because it matches everything) and print "Invalid month.", but the solution says that case 3 "March" is correct?
Can you please explain this? Thank you.
Even though your default is in the middle of other case statements, this doesn't mean the case labels after the default will be ignored. Since the switch expression is 3, so the case labeled 3 will be a match and thus the default case won't be used...