Multiple choice technology programming languages

package testswitch; public class TestSwitch1 { public static void main(String[] args) { int m=100; switch(100) { case m: System.out.println("in m"); default :System.out.println("default"); } } }

  1. in m Default

  2. Compiler Error

  3. in m

  4. default

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

Compilation fails because the case label expression m is not a constant expression. In Java, switch case labels must be constant expressions (like literals or variables declared as static final). Because m is a standard local variable, it cannot be used as a case label.