nerdexam
Oracle

1Z0-804 · Question #49

Given the code fragment: What is the result, if the file myfile.txt does not exist?

The correct answer is D. Compilation fails. !! Compilation fails if FileNotFoundException is tried to catch (Line 12) (The exception FileNotFoundException is already caught by the alternative IOException) -------------------------------- --------------------------------------------------------------- if this is removed…

NIO.2

Question

Given the code fragment:

What is the result, if the file myfile.txt does not exist?

Exhibit

1Z0-804 question #49 exhibit

Options

  • AA runtime exception is thrown at line 4
  • BA runtime exception is thrown at line 7
  • CCreates a new file and prints no output
  • DCompilation fails

How the community answered

(34 responses)
  • A
    9% (3)
  • B
    3% (1)
  • C
    12% (4)
  • D
    76% (26)

Explanation

!! Compilation fails if FileNotFoundException is tried to catch (Line 12) (The exception FileNotFoundException is already caught by the alternative IOException) -------------------------------- --------------------------------------------------------------- if this is removed will be thrown a FileNotFoundException at line 4.

Topics

#Path#Files API#StandardOpenOption#checked exception

Community Discussion

No community discussion yet for this question.

Full 1Z0-804 Practice