Showing posts with label default. Show all posts
Showing posts with label default. Show all posts

Saturday, 5 November 2011

Sun Certified Java Programmer (SCJP)-9

What will be printed out if you attempt to compile and run the following code?

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");


}


Choices:

  • A. default

  • B. default, zero, one

  • C. Compiler error

  • D. No output displayed


Correct choice:  B

Explanation: