41.4k views
5 votes
Is the type of the exception object that gets thrown always the same as the exception type declared in the catch clause that catches the exception? If not, why not?

User Belia
by
4.4k points

1 Answer

3 votes

Answer:

Yes is the correct answer for the above question.

Step-by-step explanation:

  • The exception is a run time error, which is caused during the execution of the program. for example, 100/0 is not a compile-time error but it is a run time error because divisible by 0 to any number is not possible.
  • If the exception generates, then there is a need to catch which catches the exception to stop the program for its abnormal termination.
  • If any object is thrown, then it searches his type of object to handle the exception because no other type of objects can handle the exception. It is also asked by the question. Hence yes is the answer to the above question.
User Bswinnerton
by
4.6k points