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?

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



Leave a Reply 8

Your email address will not be published. Required fields are marked *


KashiHide

KashiHide

Answer is C.

But there are a few errata here.
The line next to “Path path2…” should be like this.
Path res2 = path2.resolve(“/readme/”);

Jozef

Jozef

I impl the question, the correct answer is C

dazladhoyya

dazladhoyya

Hello could you post the code please.

smh

smh

C.
/app/./sys/log
/readme

Berti John

Berti John

C. is correct

Pinco

Pinco

Correct answer is C, tested it and some errata must be corrected in the code above

dazladhoyya

dazladhoyya

Can someone explain why the answer is C and not D