Is it possible to execute two catch blocks?

Started by beingchinmay, 01-18-2017, 00:57:54

Previous topic - Next topic

beingchinmayTopic starter

You are allowed to include more than one catch block in your program; however, it is not possible to execute them in one go. Whenever, an exception occurs in your program, the correct catch block is executed and the control goes to the finally block.


Lishmalinyjames

Yes, you can have multiple catch blocks with the try statement. You start with catching specific exceptions and then in the last block, you may catch base Exception. Only one of the catch block will handle your exception. You can have a try block without a catch block.