92.9k views
3 votes
Which of the following exceptions is a checked exception:

A.) ArithmeticException

B.) IOException

C.) RuntimeException

D.) InputMismatchException

1 Answer

3 votes

Final answer:

The correct answer is B) IOException, which is a checked exception in Java. It must be either handled within the code using try-catch or declared with throws. Other options listed are types of RuntimeExceptions, which are unchecked exceptions.

Step-by-step explanation:

The student has asked which option from a given list is a checked exception. In Java, checked exceptions are the ones that are checked at compile-time; they must be either handled using a try-catch block or declared in the method signature with the throws keyword.

Among the options provided:

  • ArithmeticException - a type of RuntimeException
  • IOException - a checked exception
  • RuntimeException - not a checked exception, but a superclass for a wide range of unchecked exceptions
  • InputMismatchException - another type of RuntimeException

Hence, the correct answer is B) IOException, which is a checked exception required to be handled or declared in Java programs when performing input and output operations that could fail.

User Alan Thomas
by
7.7k points