Exam 1z0-809 All QuestionsBrowse all questions from this exam
Question 178

Given the code fragment:

Path path1 = Paths.get("/app/./sys/");

Path res1 = path1.resolve("log");

Path path2 = Paths.get("/server/exe/");

Path res1 = path2.resolve("/readme/");

System.out.println(res1);

System.out.println(res2);

What is the result?

    Correct Answer: C

    The correct answer is that the first path resolves to '/app/./sys/log' and the second path resolves to '/readme'. The 'resolve' method when used with an absolute path (like '/readme') will ignore the starting path and use the provided absolute path as is. Therefore, '/app/./sys/' resolves to '/app/./sys/log' and '/server/exe/' with '/readme/' resolves to '/readme'.

Discussion
jduarteOption: C

the correct answer is C if the sentence Path res1 = path2.resolve("/readme/"); change por Path res2 = path2.resolve("/readme/"); because that way it doesn't compile

asdfjhfgjuaDCVOption: C

C is the correct answer

steefaandOption: C

C is correct assuming second Path is p2 instead of p1.

duydnOption: C

C is correct, tested 22/09/2023

WilsonKKerllOption: C

Answer is C.