For the questions below, use the following skeletal code. public static void mai
ID: 3779072 • Letter: F
Question
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 m1 1. it is not caught leading to the program terminating 2. it is caught in m3 3. it is caught in main 4. it is caught in m1 5. it is caught in m2
Explanation / Answer
Answer: 1. it is not caught leading to the program terminating
NullPointerException not handled either in m1() method and main method by try-catch block. So it will lead to terminate the program.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.