Given the code fragment:
Path path1 = Paths.get("/app/./sys/");
Path res1 = path1.resolve("log");
Path path2 = Paths.get("/server/exe/");
Path res1 = path2.resolve("/readme/");
System.out.println(res1);
System.out.println(res2);
What is the result?
Given the code fragment:
Path path1 = Paths.get("/app/./sys/");
Path res1 = path1.resolve("log");
Path path2 = Paths.get("/server/exe/");
Path res1 = path2.resolve("/readme/");
System.out.println(res1);
System.out.println(res2);
What is the result?
The correct answer is that the first path resolves to '/app/./sys/log' and the second path resolves to '/readme'. The 'resolve' method when used with an absolute path (like '/readme') will ignore the starting path and use the provided absolute path as is. Therefore, '/app/./sys/' resolves to '/app/./sys/log' and '/server/exe/' with '/readme/' resolves to '/readme'.
the correct answer is C if the sentence Path res1 = path2.resolve("/readme/"); change por Path res2 = path2.resolve("/readme/"); because that way it doesn't compile
C is the correct answer
C is correct assuming second Path is p2 instead of p1.
C is correct, tested 22/09/2023
Answer is C.