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

Question 105

Question ID: UKOCP42141


Given code of Test.java file:


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

  • A KEEP IT
  • B KEEP IT SIMPLE
  • C SIMPLE
  • D Compilation error
Reveal correct answer

Correct answer: D

Explanation

UKOCP42141:

At Line n2, local variable 'str' shadows the static variable 'str' created at Line n1. Hence, for the expression str + "SIMPLE", Java compiler complains as local variable 'str' is not initialized.

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