Given: What is the result?
A.
0 Done
B.
Third Exception
C.
Done Third Exception
D.
First Exception Done
E.
Second Exception
Given: What is the result?
A.
0 Done
B.
Third Exception
C.
Done Third Exception
D.
First Exception Done
E.
Second Exception
Correct answer is B.
I think the answer is D,because the static method dispResult doesn’t have a throws exception signature, the main method can’t catch the ArithmeticException. Since the method dispResult has catch the ArithmeticException, the program will complete run. It will execute the Line which print “Done” after printing “first exception”
I was wrong, the correct answer is B
b
B
num[1]-num[2]throws Exception java.lang.ArrayIndexOutOfBoundsException: 2
main can handle exception