Multiple choice

What is the output of the following code?

public void select(){int a = 2;switch(a){case 1: {System.out.println(case 1);}case 2: {System.out.println(case 2);}default: {System.out.println(default);}}}

  1. Prints case 1

  2. Prints case 2

  3. Prints case 2 default

  4. Prints case 1 case 2

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Since there is no break statement, case 2 and default will be executed.