Multiple choice technology programming languages

package testswitch; public class TestSwitch { public static void main(String[] args) { int x = 2; switch (x) { default: System.out.println("Default"); break; case 3: System.out.println("I am in 3"); break; case 2: System.out.println("I am in 2"); break; } } }

  1. I am in 2

  2. Default I am in 2

  3. Default

  4. Compiler Error

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

The output is I am in 2. The switch expression evaluates x (which is 2). The compiler matches this value directly with case 2, executing its block and printing I am in 2. The default block is only executed if no matching case is found, regardless of its position in the switch.