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

Given the code fragment:

What is the result?

    Correct Answer: A

    In the given Java code, the first statement creates a Path instance for the path '/software/././sys/readme.txt'. Using the 'normalize()' method on this path removes redundant elements like '.' and returns '/software/sys/readme.txt'. The name count for the original path ('path1') is 5 since '/software/././sys/readme.txt' consists of 5 elements. The name count for the normalized path ('path2') is 3 because '/software/sys/readme.txt' has 3 elements. When 'path2.relativize(path1)' is called, it computes the relative path from the normalized path back to the original path. The relative path between '/software/sys/readme.txt' and '/software/././sys/readme.txt' includes all the redundant path names in the original path, resulting in a total of 6 elements. Hence, the answer is '5 : 3 : 6'.

Discussion
pul26Option: A

Answer is A tested

Huim

By me answer is: 5 3 1

Svetleto13

Answer is A.I tested it with JDK8

Kim514Option: A

Path path1 = Paths.get("/software/././sys/readme.txt"); Path path2 = path1.normalize(); Path path3 = path2.relativize(path1); System.out.print(path1.getNameCount()); System.out.print(" : " + path2.getNameCount()); System.out.print(" : " + path3.getNameCount()); ---------------------------------------------------------------------------------- 5 : 3 : 1 Process finished with exit code 0

asdfjhfgjuaDCVOption: A

A is the correct answer

iSnoverOption: A

Answer is A, I tested it with JDK8.

lchowenOption: A

Using JDK8 I got 5:3:6. Answer is definitely A

Eason_from_the_futureOption: B

p1.relativize(p1).getNameCount(); // 1 p2.relativize(p1).getNameCount(); // 6