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

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?

    Correct Answer: C

    When resolving paths in Java, the resolve method is used to combine two paths. Given the code fragment: Path path1 = Paths.get('/app/./sys/'); Path res1 = path1.resolve('log'); generates the path '/app/./sys/log'. Next, Path res2 = path1.resolve('/readme/'); where '/readme/' is an absolute path, the result is '/readme/' itself. Therefore, the output will be '/app/./sys/log' and '/readme/'. Thus, the correct answer is C.

Discussion
InnovationOption: C

C is correct, tested

adnano1234Option: A

A is correct

adnano1234

Sorry I meant C

asdfjhfgjuaDCVOption: C

C is the correct answerr

steefaandOption: C

Answer is C, it will be just printed in new line because of println.

WilsonKKerllOption: C

Answer is C.