What will the following code print?
enum Season {/* www.j av a2 s . c o m*/ SUMMER, WINTER, SPRING, FALL } public class Main { public static void main(String[] args) throws Exception { Season s = Season.SPRING; switch (s){ case SUMMER : System .out.println ("SUMMER"); case default : System .out.println ("SEASON"); case WINTER : System .out.println ("WINTER"); } } }
Select 1 option
Correct Option is : C
If the code is changed to default: System .out.println ("SEASON"); it will print SEASON WINTER.
Since there is no break after the case statements, the control will go through the rest of the case statements without even checking the value of the cases.