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

Question 106

Question ID: UKOCP50130


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

  • A 5
  • B 10
  • C 30
  • D 120
Reveal correct answer

Correct answer: D

Explanation

UKOCP50130:

Matching case block 'case 10:' is found, a *= 2; is executed, which means a = a * 2; => a = 5 * 2; => a = 10; 

No break statement, hence it enters in fall-through. 

a *= 3; is executed, which means a = a * 3; => a = 10 * 3; => a = 30; 

a *= 4; is executed, which means a = a * 4; => a = 30 * 4; => a = 120;

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