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

Question 55

Question ID: UKOCP38399


Given code:


What is the result?

  • A

    Book.java

    Book.java

  • B

    F:\A\B\Book.java

    F:\A\B\C\Book.java

  • C

    F:\A\B\C\Book.java

    F:\A\B\Book.java

  • D

    F:\A\B\C\Book.java

    Book.java

  • E

    Book.java

    F:\A\B\Book.java

Reveal correct answer

Correct answer: C

Explanation

UKOCP38399:

Variables 'file1' and 'file2' infer to Path type.

Method Paths.get(...) converts a path String, or a sequence of strings that when joined form a path string, to a Path.


file1.resolve(file2) resolves file2 against file1. file1 is an absolute path and file2 is a relative path, hence resolve method returns Path object referring to 'F:\A\B\C\Book.java'.


file1.resolveSibling(file2) resolves file2 against parent path of file1. Parent path of file1 is: 'F:\A\B\', hence resolveSibling method returns Path object referring to 'F:\A\B\Book.java'.

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