Multiple choice technology architecture

What will be printed out if you attempt to compile and run the following code? int i=9; switch (i) { default: System.out.println("default"); case 0: System.out.println("zero"); break; case 1: System.out.println("one"); case 2: System.out.println("two"); }

  1. default

  2. default, zero

  3. error default clause not defined

  4. no output displayed

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

When i=9, no case matches, so default executes. The default clause lacks a break statement, causing fall-through to case 0, which prints 'zero'. Thus both 'default' and 'zero' are printed.