Multiple choice technology programming languages

package testswitch; public class TestSwitch5 { public static void main(String[] args) { char a = 'a'; switch (a) { default: System.out.println("I am in default"); break; case 'a': System.out.println("I am in a"); break; } } }

  1. I am in a

  2. I am in default

  3. Exception

  4. Compiler Error

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

The switch expression is char a with value 'a'. The code has a default case first followed by case 'a'. Since the value 'a' matches case 'a' exactly, Java executes that case and prints "I am in a", then breaks out of the switch statement.