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

Question 40

Question ID: UKOCP16131


F: is accessible for reading/writing and below is the directory structure for F:

           

Given code of Test.java file:


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

  • A Above program executes successfully and prints nothing on to the console
  • B

    Above program executes successfully and prints below lines on to the console:

    F:Parent\a.txt

    F:Parent\b.txt

  • C

    Above program executes successfully and prints below lines on to the console:

    F:Parent\Child\c.txt

    F:Parent\Child\d.txt

    F:Parent\a.txt

    F:Parent\b.txt

  • D Compilation error
Reveal correct answer

Correct answer: D

Explanation

UKOCP16131:

endsWith method is overloaded in Path interface:

boolean endsWith(Path other);

boolean endsWith(String other);


p.endsWith(null) causes compilation error as it is an ambiguous method call.

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