Oracle Certified Associate Java Se 8 Programmer · Free Practice Question Hard

Question 48

Consider the following code:

What is the result?

  • A

    10100

  • B

    10

  • C

    Nothing will be printed to the console.

  • D

    101001000

Reveal correct answer

Correct answer: C

Explanation

Every case label should be within the range of switch argument type. In the above code switch argument 'b+1' is of int type. All case labels are within the range only. Hence we won't get any compile time error. But no case is matched and hence we won't ger any output.

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need