Java OCA OCP Practice Question 314

Question

Given the following statements:

  • I. A nonempty directory can usually be deleted using Files.delete
  • II. A nonempty directory can usually be moved using Files.move
  • III. A nonempty directory can usually be copied using Files.copy

Which of the following is true?

  • A. I only
  • B. II only
  • C. III only
  • D. I and II only
  • E. II and III only
  • F. I and III only
  • G. I, II, and III


E is correct because a directory containing files or subdirectories is copied or moved in its entirety.

Note

Main can only be deleted if they are empty.

Trying to delete a nonempty directory will throw a DirectoryNotEmptyException.

The question says "usually" because copy and move success depends on file permissions.

Think about the most common cases when encountering words such as "usually" on the exam.




PreviousNext

Related