What is the output of the following code snippet? Assume that the current directory is the root path.
Path p1 = Paths.get("./found/../keys"); Path p2 = Paths.get("/lost/data.txt"); System.out.println(p1.resolve(p2)); System.out.println(p2.resolve(p1));
A. /lost/data.txt //ww w .j a va 2 s . com ./found/../keys B. /found/../keys/./lost/data.txt /lost/data.txt/keys C. /lost/data.txt /lost/data.txt/./found/../keys D. None of the above
C.
First off, p2 is an absolute path, which means that p1.resolve(p2) just returns p2.
Option B is incorrect.
Since p1 is a relative path, it is appended onto p2, making Option C correct and Option A incorrect.