Exam 1z0-819 All QuestionsBrowse all questions from this exam
Question 204

Given the code fragment:

You must define the A exception class. The program execution must be terminated if the condition at line 19 is true and an A exception is thrown at line 20.

Which code fragment at line n1 defines A as per the requirement?

    Correct Answer: A

    In order for the program execution to terminate immediately when the A exception is thrown, the A class should extend Throwable directly. If A extends Exception, it will be caught by the catch block, and the program will continue to the next line, printing 'Continue...'. Extending Throwable ensures that the exception is not caught by the catch block and thus terminates the program.

Discussion
d7bb0b2Option: A

a IS CORRECT for finish program in line 20, others catch in exception clause an conitnue program

ASPushkinOption: A

see below

ASPushkinOption: A

answer : A B is not correct According to the source code only exceptions extended from Throwable type and not from an Exception type are not caught. It could be Error or even checked type of exception.