Multiple choice technology programming languages

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

Since i is 9, it matches no explicit case, transferring control to the default block. Because there is no break statement at the end of the default block, execution falls through to execute case 0 print statement, outputting both 'default' and 'zero'.