Java SE 11 Developer (1Z0-819) — Question 14

Given:
Path p1 = Paths.get(“/scratch/exam/topsecret/answers”);
Path p2 = Paths.get(“/scratch/exam/answers/temp.txt”);
Path p3 = Paths.get(“/scratch/answers/topsecret”);
Which two statements print ..\..\..\answers\topsecret? (Choose two.)

Answer options

Correct answer: B, C

Explanation

The correct answers are B and C because they both calculate the relative paths from one directory to another resulting in .. elative paths that lead to answers/topsecret. The other options do not produce this specific relative path, as they either go in the wrong direction or do not match the required output.