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

Given the code fragment:

What change on line 1 will make this code compile?

    Correct Answer: B

    In Java, the exception M is a subclass of L and thus can be caught by a catch block that handles exceptions of type L. Therefore, adding catch(L e) is sufficient to catch both M and L exceptions, making the code compile successfully. Catching L will automatically catch both M and L exceptions because M extends L. Other options like catching multiple exceptions with a multi-catch block are unnecessary and may result in compilation errors if subclasses are included inappropriately.

Discussion
ASPushkinOption: B

answer : BD Exception classes specified inmulticatch statement cannot be subclasses. The order of the exception classes does not affect its execution. A,C,E - not correct - subclasses

d7bb0b2Option: B

B is correct, is just a change needs to compile, D=> is also correct but the answer that are nor releated excepcion but, with B opcion can capture All expcionts

dilleman

B and D will compile (tested).

[Removed]Option: B

B is the most correct one. But D will also compile

StavokOption: B

B is correct Tested