CJCoding With Joseph
15per day
← Back to Question List
Java Code Walkthrough #26

Switch Fall Through With Break

mediumIf Statements

📄 Code

Read carefully — what does this print?
1public class Main {
2 public static void main(String[] args) {
3 int x = 2;
4 
5 switch (x) {
6 case 1:
7 System.out.print("A");
8 case 2:
9 System.out.print("B");
10 case 3:
11 System.out.print("C");
12 break;
13 default:
14 System.out.print("D");
15 }
16 
17 System.out.println();
18 }
19}

🎯 Your Answer