Example Code Ch 11-1
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) {...}
}
}
-Refer to Example Code Ch 11-1: If a NullPointerException arises in the try statement in m1
A) it is caught in main
B) it is caught in m1
C) it is caught in m2
D) it is caught in m3
E) it is not caught and the program terminates
Correct Answer:
Verified
Q3: Which of the following messages passed to
Q4: The difference between the throw reserved word
Q5: Programmers can define their own exceptions by
Q6: If an exception is thrown and not
Q7: NullPointerExceptions and ArithmeticExceptions are both derived from
Q9: A try statement must have at least
Q10: While the Exception class is part of
Q11: A Java program can handle an exception
Q12: All run-time errors throw exceptions.
Q13: If an exception arises in a catch
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents