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?
A. /app/sys/log
/readme/server/exe
B. /app/log/sys
/server/exe/readme
C. /app/./sys/log
/readme
D. /app/./sys/log
/server/exe/readme
C
Question has typo -> it should read
Path res2 = path2.resolve(“/readme/”);
instead of
Path res1 = path1.resolve(“/readme/”);
I miss answer E compilation fails
The declartion of res1 is done twice -> your compiler will know
No declaration of res2 which is used in lae last line of the snippet. -> again compile failure
C
/readme/ will be resolved as /readme (if its just “readme” in quesion then it will resolve as /server/exe/readme).
So answer will be : C
/aap/./sys/log
/readme
The Correct Answer Is : C
C
c