beginnerOOP & Core Syntax

Can you catch multiple exception types in a single catch block?

Yes, using multi-catch syntax introduced in Java 7: catch (IOException | SQLException e) { ... } — this avoids duplicating the same handling logic across multiple catch blocks. The caveat: the exception types in a multi-catch can't be related by inheritance (you can't combine a class and its own subclass), and the resulting variable e is implicitly final.

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to Why can increasing the thread pool size actually reduce application performance?← Back to all Core Java questions