Exam Permalink:
https://www.jobilize.com/java-certification-questions
Question Permalink:
https://www.jobilize.com/java-switch-statement-rules
Question 235 / 297:  what will be the output of compiling and running this code:
class TestByte{

public static void main(String arg[])

{

final Integer a=10;

int b=2;

switch(b)

{

case 1: System.out.println("1");

break;

case 2: System.out.println("2");

break;

case a: System.out.println("3");

break;

}

}

}

A  compiler error
B  prints 2
C  Runtime exception is generated.
D  prints 3
<< First < Previous Next > Last >>
Explanation:

variable after case should be a conatant.

Exam Home Page
https://www.jobilize.com/java-certification-questions

Oracle Certified Professional Java Programmer

Author:

Access: Public Instant Grading

Ask
Edgar Delgado
Start Test
Yacoub Jayoghli
Start Quiz
Copy and paste the following HTML code into your website or blog.
<iframe src="https://www.jobilize.com/embed/java-certification-questions" width="600" height="600" frameborder="0" marginwidth="0" marginheight="0" scrolling="yes" style="border:1px solid #CCC; border-width:1px 1px 0; margin-bottom:5px" allowfullscreen webkitallowfullscreen mozallowfullscreen> </iframe>