Which two modifications, made independently, will allow the program to compile?

A method doSomething () that has no exception handling code is modified to trail a method
that throws a checked exception. Which two modifications, made independently, will allow
the program to compile?

A method doSomething () that has no exception handling code is modified to trail a method
that throws a checked exception. Which two modifications, made independently, will allow
the program to compile?

A.
Catch the exception in the method that calls doSomething().

B.
Cast the exception to a RunTimeException in the doSomething() method.

C.
Declare the exception to be thrown in the doSomething() method signature.

D.
Catch the exception in the method doSomething().



Leave a Reply 5

Your email address will not be published. Required fields are marked *


shevin

shevin

Why not A?

De21

De21

method doSomething () throws a checked exception

Mario

Mario

Because doSomething method must declare Exception to be thrown in his method signature in order to catch the eception where the method is invoked.

Zizipho

Zizipho

How can I implement this question in a code?