Multiple choice technology programming languages

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

  1. one

  2. one default

  3. one two default

  4. default

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

In Java switch statements, execution falls through to the next case when a break statement is missing. Since i=1 matches case 1, it prints 'one', then continues to case 2 printing 'two', then to default printing 'default'. Without break statements after each case, all subsequent code executes.