Catching Subclass Exceptions

If a catch handler is written to catch superclass exception objects, it can also catch all objects of that class’s subclasses. This enables catch to handle related exceptions polymorphically. You can catch each subclass individually if those exceptions require different processing.

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.