nerdexam
Oracle

1Z0-805 · Question #8

Given the following code fragment: public static void main(String[] args) { Path tempFile = null; try { Path p = Paths.get("emp"); tempFile = Files.createTempFile(p, "report", ".tmp"); try…

Sign in or unlock 1Z0-805 to reveal the answer and full explanation for question #8. The question stem and answer options stay visible for context.

Java I/O Fundamentals

Question

Given the following code fragment:

public static void main(String[] args) { Path tempFile = null; try { Path p = Paths.get("emp"); tempFile = Files.createTempFile(p, "report", ".tmp"); try (BufferedWriter writer = Files.newBufferedWriter(tempFile, Charset.forName("UTF8")))){ writer.write("Java SE 7"); } System.out.println("Temporary file write done"); } catch(IOException e) { System.err.println("Caught IOException: " + e.getMessage()); } Oracle 1Z0-805 Exam } What is the result?

Options

  • AThe report.tmp file is purged during reboot.
  • BThe report.tmp file is automatically purged when it is closed.
  • CThe report.tmp file exists until it is explicitly deleted.
  • DThe report.tmp file is automatically purged when the execution of the program completes.

Unlock 1Z0-805 to see the answer

You've previewed enough free 1Z0-805 questions. Unlock 1Z0-805 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.

Topics

#createTempFile#temp file lifecycle#NIO.2#BufferedWriter
Full 1Z0-805 Practice