nerdexam
Oracle

1Z0-804 · Question #47

Given the code fragment: What is the result when infected() is invoked?

The correct answer is D. before catch finally. The following line throws and exception: This exception is caught by: catch(Exception e) { System.out.print("catch "); Lastly, the finally statement is run as the finally block always executes when the try block exits. This ensuresthat the finally block is executed even if an…

Exceptions and Assertions

Question

Given the code fragment:

What is the result when infected() is invoked?

Options

  • Abefore try catch finally after
  • Bbefore catch finally after
  • Cbefore catch after
  • Dbefore catch finally
  • Ebefore catch

How the community answered

(26 responses)
  • B
    15% (4)
  • C
    4% (1)
  • D
    73% (19)
  • E
    8% (2)

Explanation

The following line throws and exception: This exception is caught by: catch(Exception e) { System.out.print("catch "); Lastly, the finally statement is run as the finally block always executes when the try block exits. This ensuresthat the finally block is executed even if an unexpected exception occurs.

Topics

#try-catch-finally#control flow#exception propagation#return in finally

Community Discussion

No community discussion yet for this question.

Full 1Z0-804 Practice