Exam 1z0-809 All QuestionsBrowse all questions from this exam
Question 77

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?

    Correct Answer: B

    The green.txt file is moved to /colors/yellow.txt atomically, which means the operation is carried out as a single unit of work without interfering failures. After this, the system attempts to delete the source file green.txt. However, since the file has already been moved and thus no longer exists at the original location, a NoSuchFileException will be thrown.

Discussion
pul26Option: B

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

varconiteOption: B

Answer is B

Svetleto13Option: B

B,tested

f8eddy

Why not d?

asdfjhfgjuaDCVOption: B

B is the correct answer

steefaandOption: B

B since source file doesn't exist anymore.

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

NaponeonOption: B

Answer is B