Oracle Certified Associate Java Se 8 Programmer · Free Practice Question Hard

Question 11

Consider the code:

What is the result?

  • A

    Compilation Fails.

  • B

    ABCD followed by NullPointerException

  • C

    ABC followed by NullPointerException

  • D

    ABCD followed by ArithmeticException

Reveal correct answer

Correct answer: B

Explanation

Inside try ArithmeticException raised and hence catch block will be executed. But within the catch block NullPointerException will be raised, which is uncaught. Hence the program will be terminated abnormally. But before abnormal termination, only finally block will be executed. Hence the output is: ABCD followed by NullPointerException

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need