Given the code fragment:
Path path1 = Paths.get("/app/./sys/");
Path res1 = path1.resolve("log");
Path path2 = Paths.get("/server/exe/");
Path res2 = 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 res2 = 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/");` and `Path res1 = path1.resolve("log");` results in /app/./sys/log. This is because resolve adds the 'log' segment to the existing path without normalizing the path (i.e., it does not remove the './'). Next, `Path path2 = Paths.get("/server/exe/");` and `Path res2 = path2.resolve("/readme/");` results in /readme. When resolving an absolute path, the result is the absolute path itself, so the parent path is ignored. Therefore, the output will be /app/./sys/log /readme.
Answer C. Tested
C is correct.
The answer is C, it prints "/app/./sys/log /readme"
Answer is C.