✏️ Explanatory Question

What classes of exceptions may be caught by a catch clause?

👁 27 Views
📘 Detailed Answer
🟢 Easy
💡

Answer with Explanation

A catch clause can catch any exception that is a subclass of the Throwable class.
This includes both:

  • Error (serious system errors), and

  • Exception (runtime or checked exceptions).

For example:


catch (Throwable t) {
    System.out.println("Caught any type of throwable error or exception");
}