Exam 1z0-809 All QuestionsBrowse all questions from this 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.

    Correct Answer: A

    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
InnovationOption: 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.

AVB22Option: A

A tested

DarGrinOption: A

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

steefaandOption: A

A is correct.

iSnoverOption: A

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.