As you already know about the Switch statement, it can contain any number of cases. Each case may or may not followed by a break statement. Because the break statement is optional for each block. You can’t force the user to provide a break statement for each case. So in this article, we will read how behaves Switch case without break statement.
Why the break statement is used?
The break statement is used inside the switch to terminate a statement sequence and jumps the control after the switch expression. Whenever a break statement is found in the Switch statement the control flow directly jumps to out of Switch statement.
NOTE: If a break statement is not used in any case the execution will continue into the next case until a break statement is reached. If no break statement found in any case then it executes all the cases including the default case. It is also known as fall-through.
Syntax
switch(variable/expression) { case value1 : // code inside the case value1 // Break is not used because it is optional case value2 : // code inside the case value2 // Break is not used because it is optional . . . default : // code inside the default case. }
In Syntax, you can see the break statement is optional.
public class ExampleOfSwitch { public static void main(String[] args) { //Declaring a variable for switch expression int noOfDays = 28; switch(noOfDays) //Switch expression { //Case statements case 28: System.out.println("Only February month has 28 days"); // NOTE: There is no break statement after the case 28 case 30: System.out.println("April, June, August, October, December has 30 days"); break; case 31: System.out.println("January, March, May, July, September, November has 31 days"); break; //Default case statement default: System.out.println("Please enter valid no of days"); } } }
Output: Only February month has 28 days
April, June, August, October, December has 30 days

You can see in the example: Compiler doesn’t find the break statement after the case 28 and it executes the next case also.
check the answer is correct or not
Hi Priya
It shows an instant reply when you choose the option. The green color is used for the correct answer.
Doesn’t turn green or red with me as well. Tried turning off dark reading mode, but no help.