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

Question 20

Question ID: UKOCP19766


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

  • A 25-25
  • B 35-25
  • C 35-60
  • D 25-60
Reveal correct answer

Correct answer: D

Explanation

UKOCP19766:

In below statements: student<main> means student inside main method.

On execution of main method: student<main> --> {"James", 25}, marks<main> = 25.

On execution of review method: stud<review> --> {"James", 25} (same object referred by student<main>), marks<review> = 25 (this marks is different from the marks defined in main method). marks<review> = 35 and stud.marks = 60. So at the end of review method: stud<review> --> {"James", 60}, marks<review> = 35.

Control goes back to main method: student<main> --> {"James", 60}, marks<main> = 25. Changes done to reference variable are visible in main method but changes done to primitive variable are not reflected in main method.

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