nerdexam
Oracle

1Z0-804 · Question #54

Given the code fragment: Which code fragment inserted at line ***, enables the code to compile?

The correct answer is E. public void process (){. A: Compilation fails: Exception IOException is not compatible with throws clause in B: Compilation fails: Exception IOException is not compatible with throws clause in C: Compilation fails: Exception Exception is not compatible with throws clause in Base.process() D…

Exceptions and Assertions

Question

Given the code fragment:

Which code fragment inserted at line ***, enables the code to compile?

Exhibit

1Z0-804 question #54 exhibit

Options

  • Apublic void process () throws FileNotFoundException, IOException {
  • Bpublic void process () throws IOException {
  • Cpublic void process () throws Exception {
  • Dpublic void process (){
  • Epublic void process (){

How the community answered

(37 responses)
  • A
    5% (2)
  • B
    8% (3)
  • C
    14% (5)
  • D
    3% (1)
  • E
    70% (26)

Explanation

A: Compilation fails: Exception IOException is not compatible with throws clause in B: Compilation fails: Exception IOException is not compatible with throws clause in C: Compilation fails: Exception Exception is not compatible with throws clause in Base.process() D: Compilation fails: Exception FileNotFoundException has already been caught by the alternative IOException Alternatives in a multi-catch statement cannot be related to subclassing Alternative java.io.FileNotFoundException is a subclass of alternative java.io.IOException

Topics

#throws declaration#checked exception#method signature#IOException

Community Discussion

No community discussion yet for this question.

Full 1Z0-804 Practice