nerdexam
Oracle

1Z0-804 · Question #115

Given the code fragment: And a DOS-based file system: Which option, containing statement(s), inserted at line 3, creates the file and sets its attributes to hidden and read-only?

The correct answer is D. Files.createFile(file). You can set a DOS attribute using the setAttribute(Path, String, Object, LinkOption...) method, as Path file = ...; Files.setAttribute(file, "dos:hidden", true); public static Path setAttribute(Path path, String attribute, LinkOption... options) throws IOException Sets the…

NIO.2

Question

Given the code fragment:

And a DOS-based file system:

Which option, containing statement(s), inserted at line 3, creates the file and sets its attributes to hidden and read-only?

Options

  • ADOSFileAttributes attrs = Files.setAttribute(file,"dos:hidden","dos: readonly")
  • BFiles.craeteFile(file);
  • CFiles.createFile(file,"dos:hidden","dos:readonly");
  • DFiles.createFile(file);

How the community answered

(33 responses)
  • A
    3% (1)
  • B
    9% (3)
  • C
    3% (1)
  • D
    85% (28)

Explanation

You can set a DOS attribute using the setAttribute(Path, String, Object, LinkOption...) method, as Path file = ...; Files.setAttribute(file, "dos:hidden", true); public static Path setAttribute(Path path, String attribute, LinkOption... options) throws IOException Sets the value of a file attribute.

Topics

#NIO.2#Files#DOS attributes#file creation

Community Discussion

No community discussion yet for this question.

Full 1Z0-804 Practice