Exam 1z0-809 All QuestionsBrowse all questions from this exam
Question 219

Given the code fragment:

Path p1 = Paths.get("/Pics/MyPic.jpeg");

System.out.println (p1.getNameCount() +

":" + p1.getName(1) +

":" + p1.getFileName());

Pics directory does NOT exist.

Assume that the -

What is the result?

    Correct Answer: B

    When using the Paths.get method, the given path is divided into names by the forward slash delimiter. Here, the path "/Pics/MyPic.jpeg" consists of two names: "Pics" and "MyPic.jpeg". Thus, p1.getNameCount() returns 2. p1.getName(1) refers to the second element in the path, which is "MyPic.jpeg", and p1.getFileName() returns the name of the file itself, which is "MyPic.jpeg". Therefore, the output will be 2:MyPic.jpeg: MyPic.jpeg.

Discussion
Ritesh_Option: B

Answer is B

DestroyerOption: B

The correct answer is B (Tested)

InnovationOption: B

B tested

steefaandOption: B

B is correct.

iSnoverOption: B

The correct answer is B.

WilsonKKerllOption: B

B, teseted.