1z0-809 Exam QuestionsBrowse all questions from this exam

1z0-809 Exam - Question 247


/green.txt and /colors/yellow.txt are accessible, and the code fragment:

Given that -

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?

green.txt file content is replaced by the yellow.txt file content and the yellow.txt file is deleted.

Show Answer
Correct Answer: AD

The yellow.txt file content is replaced by the green.txt file content and an exception is thrown. The move operation succeeds in moving green.txt to /colors/yellow.txt. After the move, the source file (green.txt) no longer exists at its original location because it has been moved. Trying to delete the source file after it has been moved will result in an exception.

Discussion

5 comments
Sign in to comment
InnovationOption: A
Jan 16, 2020

The yellow.txt file content is replaced by the green.txt file content Then a NoSuchFileException is thrown. because cant find the source file to delete.

AVB22Option: A
Nov 11, 2021

A tested

iSnoverOption: A
Feb 8, 2024

The answer is A. The yellow.txt file content is replaced by the green.txt file content. Then a NoSuchFileException is thrown, because cant find the source file to delete.

steefaandOption: A
Feb 8, 2024

A is correct.

DarGrinOption: A
Jun 8, 2024

Files.delete(source); - here commes exception, because source does not exists any more