Question: Which throws clause should be inserted at (1) for the overriding method compute() in the following code so that the code will compile without errors?
Which throws clause should be inserted at (1) for the overriding method compute() in the following code so that the code will compile without errors?

Select the one correct answer.
(a) No throws clause is necessary.
(b) throws ArithmeticException
(c) throws InterruptedException
(d) throws RuntimeException
(e) throws ArithmeticException, InterruptedException
class A { // InterruptedException is a direct subclass of Exception. void compute () throws ArithmeticException, InterruptedException { div(5, 5); } } int div(int i, int j) throws ArithmeticException { return i/j; } public class Client extends A { void compute() /* (1) INSERT throws CLAUSE HERE. */ { try { div(5, 0); } catch (ArithmeticException e) { return; } throw new Runtime Exception ("ArithmeticException was expected.");
Step by Step Solution
3.32 Rating (152 Votes )
There are 3 Steps involved in it
a Overriding methods can specify all none or a subset of the checked exceptions t... View full answer
Get step-by-step solutions from verified subject matter experts
