CJCoding With Joseph
15free / daySign inCreate account
Back to Code Walkthrough

Switch Fall Through With Break

Java code walkthrough · Question 26
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