Question: Can you please help me which one is correct? For the questions below, use the following skeletal code. public static void main(String[ ] args) {
Can you please help me which one is correct?
For the questions below, use the following skeletal code.
public static void main(String[ ] args) { try { ExceptionThrowerCode etc = new ExceptionThrowerCode( ); etc.m1( ); etc.m2( ); } catch (ArithmeticException ae) { ... } } public class ExceptionThrowerCode { ... public void m1( ) { ... } public void m2( ) { try { m3(); } catch(ArithmeticException ae) {...} catch(NullPointerException npe) {...} } public void m3( ) { try { ... } catch(ArithmeticException ae) {...} } } If a NullPointerException arises in the try statement in m3 where will it be caught? If an ArithmeticException arises in the try statement in m3, where will it be caught?
Select one:
a. NullPointerException is not caught leading to the program terminating ArithmeticException is caught in m2
b. NullPointerException will be caught in m2 ArithmeticException is caught in m3 NullPointerException will be caught in m2 ArithmeticException is caught in m3
c. NullPointerException is not caught leading to the program terminating ArithmeticException is caught in main
d. NullPointerException will be caught in main ArithmeticException is caught in main
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
