Is it possible to execute two catch blocks?

Author Topic: Is it possible to execute two catch blocks?  (Read 4190 times)

Offline beingchinmayTopic starter

  • Trade Count: (0)
  • Jr. Member
  • **
  • Thank You 1
  • Posts: 73
  • Karma: 0
  • Gender: Male
  • I am Chinmay
    • Modular Kitchen Designer
Is it possible to execute two catch blocks?
« on: 01-18-2017, 00:57:54 »
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.


Offline Lishmalinyjames

  • Trade Count: (0)
  • Hero Member
  • *****
  • Thank You 3
  • Posts: 797
  • Karma: 0
    • Oneplus Service Center in Chennai
Re: Is it possible to execute two catch blocks?
« Reply #1 on: 03-25-2021, 01:46:16 »
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.


 

Related Topics

  Subject / Started by Replies Last post
0 Replies
2204 Views
Last post 10-04-2010, 12:11:33
by nick8609