Multiple choice

Which of the following statements is/are true?

(a) File(<path>) can return directory status. (b) File(<file name>) can return file status.

  1. Both (a) and (b)

  2. Only (a)

  3. Only (b)

  4. None of these

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The Java File constructor can accept both directory paths and file paths - it represents an abstract path that may refer to either. File objects can be used to check status of both directories (via isDirectory()) and regular files (via isFile()).