---
title: "What is the default switch case?"  
description: "What is the default switch case?"  
author: "Shrikant Mishra"  
published: 2019-08-27  
updated: 2019-08-27  
canonical: https://www.mindstick.com/forum/95291/what-is-the-default-switch-case  
category: "java"  
tags: ["java"]  
reading_time: 1 minute  

---

# What is the default switch case?

[switch case](https://www.mindstick.com/forum/725/if-condition-inside-switch-case) in [Java](https://www.mindstick.com/articles/12214/web-development-company-in-india-laid-on-the-foundation-of-concrete-java-programming)

## Replies

### Reply by Shrikant Mishra

Ans: In a [switch](https://www.mindstick.com/blog/104495/switch-bringing-new-advancements-in-the-education-management-system) statement, the default case is executed when no other switch condition matches. The default case is an optional case. It can be declared only once all other switch cases have been coded.

In the below example, when the score is not 1 or 2, the 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");
                break;
            case 2:
                system.out.println("Score is 2");
                break;
            default:
                system.out.println("Default Case");
        }
    }
}
```


---

Original Source: https://www.mindstick.com/forum/95291/what-is-the-default-switch-case

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
