What is the result?

Given the code fragment:
Path path1 = Paths.get(“/app/./sys/”);
Path res1 = path1.resolve(“log”);
Path path2 = Paths.get(“/server/exe/”);
Path res1 = path1.resolve(“/readme/”);
System.out.println(res1);
System.out.println(res2);
What is the result?
A. /app/sys/log
/readme/server/exe
B. /app/log/sys
/server/exe/readme
C. /app/./sys/log
/readme
D. /app/./sys/log
/server/exe/readme

Download Printable PDF. VALID exam to help you PASS.

7 thoughts on “What is the result?

  1. C

    Question has typo -> it should read
    Path res2 = path2.resolve(“/readme/”);
    instead of
    Path res1 = path1.resolve(“/readme/”);

  2. I miss answer E compilation fails
    The declartion of res1 is done twice -> your compiler will know
    No declaration of res2 which is used in lae last line of the snippet. -> again compile failure

    1. /readme/ will be resolved as /readme (if its just “readme” in quesion then it will resolve as /server/exe/readme).

      So answer will be : C
      /aap/./sys/log
      /readme

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.