exam questions

Exam 1z0-809 All Questions

View all questions & answers for the 1z0-809 exam

Exam 1z0-809 topic 1 question 20 discussion

Actual exam question from Oracle's 1z0-809
Question #: 20
Topic #: 1
[All 1z0-809 Questions]

Given the code fragment:
Path p1 = Paths.get("/Pics/MyPic.jpeg");
System.out.println (p1.getNameCount() +
":" + p1.getName(1) +
":" + p1.getFileName());
Assume that the Pics directory does NOT exist.
What is the result?

  • A. An exception is thrown at run time.
  • B. 2:MyPic.jpeg: MyPic.jpeg
  • C. 3:.:MyPic.jpeg
  • D. 2:Pics: MyPic.jpeg
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Huim
Highly Voted 3 years, 2 months ago
Answer is B, even when the directory does not exist.
upvoted 7 times
Svetleto13
3 years, 2 months ago
Yes correct i realized after.
upvoted 2 times
...
...
Svetleto13
Highly Voted 3 years, 3 months ago
B,tested
upvoted 5 times
Svetleto13
3 years, 2 months ago
I didnt see that pics directory does NOT exist.So answer is A.
upvoted 2 times
...
...
asdfjhfgjuaDCV
Most Recent 4 months, 4 weeks ago
B is the correct answer. import java.nio.file.Path; import java.nio.file.Paths; public class PathExample { public static void main(String[] args) { Path p1 = Paths.get("/Pics/MyPic.jpeg"); System.out.println(p1.getNameCount() + ":" + p1.getName(1) + ":" + p1.getFileName()); } }
upvoted 1 times
...
steefaand
5 months, 4 weeks ago
Selected Answer: B
B is correct.
upvoted 1 times
...
duydn
10 months, 2 weeks ago
Selected Answer: B
Root not considered to count -> getName(1) -> MyPic.jpeg
upvoted 1 times
...
r1muka5
1 year, 5 months ago
Correct answer is B. If it does not exist, an exception will be thrown when attempting to perform certain operations on the p1 object, such as reading or writing to the file.
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago