Multiple choice technology programming languages

int i = 3; switch (i) { default: System.out.println("default"); case 0: System.out.println("zero"); case 1: System.out.println("one"); break; case 2: System.out.println("two"); }

  1. default

  2. default, zero, one

  3. Compiler error

  4. No output displayed

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

The switch expression evaluates to i = 3. Since no case matches 3, the execution jumps to the default label. Because there is no break statement after the default, case 0, and case 1 statements, execution falls through all of them until a break is encountered in case 1, printing 'default', 'zero', and 'one'.