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?

class A { // InterruptedException is a direct subclass of Exception. void

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

1 Expert Approved Answer
Step: 1 Unlock

a Overriding methods can specify all none or a subset of the checked exceptions t... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Java Programming 8th Questions!