exam questions

Exam 1z0-809 All Questions

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

Exam 1z0-809 topic 1 question 77 discussion

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

Given that /green.txt and /colors/yellow.txt are accessible, and the code fragment:
Path source = Paths.get("/green.txt);
Path target = Paths.get("/colors/yellow.txt);
Files.move(source, target, StandardCopyOption.ATOMIC_MOVE);
Files.delete(source);
Which statement is true?

  • A. The green.txt file content is replaced by the yellow.txt file content and the yellow.txt file is deleted.
  • B. The yellow.txt file content is replaced by the green.txt file content and an exception is thrown.
  • C. The file green.txt is moved to the /colors directory.
  • D. A FileAlreadyExistsException is thrown at runtime.
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
pul26
Highly Voted 4 years, 1 month ago
ATOMIC_MOVE prevents FileAlreadyExistsException to be thrown. delete method will cause an Exception since the file is already removed by the atomic move action. Answer is B
upvoted 10 times
...
vidhuharu
Most Recent 3 months, 1 week ago
Selected Answer: D
Even with ATOMIC_MOVE, if the destination file (/colors/yellow.txt) exists and you haven’t provided REPLACE_EXISTING, a FileAlreadyExistsException will still be thrown
upvoted 1 times
...
asdfjhfgjuaDCV
10 months, 2 weeks ago
B is the correct answer
upvoted 1 times
...
steefaand
11 months, 2 weeks ago
Selected Answer: B
B since source file doesn't exist anymore.
upvoted 1 times
...
GaelBernard
1 year, 5 months ago
Selected Answer: B
B tested Exception in thread "main" java.nio.file.NoSuchFileException: green.txt A FileAlreadyExistsException is thrown only if we remove the StandardCopyOption.ATOMIC_MOVE option.
upvoted 1 times
...
Naponeon
2 years, 10 months ago
Selected Answer: B
Answer is B
upvoted 1 times
...
Svetleto13
3 years, 8 months ago
B,tested
upvoted 2 times
f8eddy
3 years, 4 months ago
Why not d?
upvoted 1 times
...
...
varconite
4 years, 1 month ago
Answer is B
upvoted 3 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