✏️ Explanatory Question

Can one catch block sufficiently trap and handle multiple exceptions?

👁 22 Views
📘 Detailed Answer
🔴 Hard
22
Total Views
10
Related Qs
0%
Progress
💡

Answer with Explanation

Yes, one catch block can handle multiple exceptions by using the multi-catch syntax (introduced in Java 7):


catch (IOException | NumberFormatException e) {
   System.out.println(e.getMessage());
}