8.6k views
2 votes
If a method throws an exception that it will not catch but that will be caught by a different method, you must also use the keyword _______ followed by an Exception type in the method header.

a. finally
b. try
c. catch
d. throws

1 Answer

3 votes

Answer:

(d) throws

Step-by-step explanation:

In some programming languages such as Java and C#, the throws keyword allows a method to specify that it is going to throw one or more exceptions but will not catch any of them but that a different method could catch them. This keyword throws is then written as part of the header of the method that is throwing the exception(s) followed by the type(s) of exception.

For example, if a method A of return type void and with no arguments, will throw an exception of type "ArithmeticException", the declaration of the header of such method should be as follows;

public void A throws ArithmeticException() {

}

User Monster
by
5.6k points