Oracle Certified Professional Java Se 11 Developer · Free Practice Question Hard

Question 110

Question ID: UKOCP26028


What will be the result of compiling and executing Test class?

  • A RUNNING
  • B SWIMMING
  • C

    SWIMMING

    FOOTBALL

  • D

    RUNNING

    TENNIS

    SWIMMING

    FOOTBALL

Reveal correct answer

Correct answer: D

Explanation

UKOCP26028:

"swimming" is different from "Swimming", so there is no matching case available. default block is executed, "RUNNING" is printed on to the console. No break statement inside default, hence control enters in fall-through and executes remaining blocks until the break; is found or switch block ends. So in this case, it prints TENNIS, SWIMMING, FOOTBALL one after another and break; statement takes control out of switch block. main method ends and program terminates successfully.

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