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?
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?
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.
Answer is B
The correct answer is B (Tested)
B tested
B is correct.
The correct answer is B.
B, teseted.