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?
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?
When resolving paths in Java, the resolve method is used to combine two paths. Given the code fragment: Path path1 = Paths.get('/app/./sys/'); Path res1 = path1.resolve('log'); generates the path '/app/./sys/log'. Next, Path res2 = path1.resolve('/readme/'); where '/readme/' is an absolute path, the result is '/readme/' itself. Therefore, the output will be '/app/./sys/log' and '/readme/'. Thus, the correct answer is C.
C is correct, tested
A is correct
Sorry I meant C
C is the correct answerr
Answer is C, it will be just printed in new line because of println.
Answer is C.