Given the code fragment:
What change on line 1 will make this code compile?
Given the code fragment:
What change on line 1 will make this code compile?
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.
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
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
B and D will compile (tested).
B is the most correct one. But D will also compile
B is correct Tested