View Full Version : What is default switch case ?

Shivangi Panwar
07-11-2016, 12:16 AM
What is default switch case ?

11-01-2016, 11:18 PM
The case statement and default statement can occur in any order of the switch statement this clause is an optional clause that is matched none of the constants in the case statement can be matched.

12-28-2016, 09:48 PM
The default clause is an optional clause that is matched if none of the constants in the case statements can be matched.

01-12-2017, 12:26 AM
The switch and case keywords evaluate expression and execute any statement associated with constant expression whose value matches the initial expression.

02-06-2017, 05:05 AM
A switch statement can have an optional default case, which must appear at the end of the switch.

02-24-2017, 12:15 AM
The switch statement is n selection control mechanism used to allow the value of the variable.

02-28-2017, 04:48 AM
In a switch statement, default case is executed when no other switch condition matches. Default case is an optional case .
It can be declared only once all other switch cases have been coded.
In the below example, when score is not 1 or 2, default case is used.

public class switchExample {
int score=4;
public static void main(String args[]) {
switch (score) {
case 1:
System.out.println("Score is 1");
case 2:
system.out.println("Score is 2");
System.out.println("Default Case");