Can multiple catch blocks be executed for a single try statement? - ProProfs Discuss
Advertisement

Can multiple catch blocks be executed for a single try statement?

Asked by Wyatt Williams, Last updated: Apr 12, 2024

+ Answer
Request
Question menu
Vote up Vote down

2 Answers

c.Dorothy

c.Dorothy

c.Dorothy
C.Dorothy

Answered Apr 18, 2018

For a single try statement, there can be multiple catches, but most often, there will only be one catch block that stops the entire thing from being seen. The idea with the catches and the reasoning behind having multiple is very simple. You want to be able to stop problems before they arise. If you point out specific issues you could see happening and want the program to stop being executed if they arise, you program them in as a catch. If the problem is encountered, the program stops. The biggest piece of advice given here is to give specific catches before less specific catches.

You would want to block the specific try-catch models from the user because this could be potentially disastrous if the user is a hacker.

upvote downvote
Reply 

Wyatt Williams

Wyatt Williams

Wyatt Williams
Wyatt Williams

Answered Oct 28, 2017

No
upvote downvote
Reply 

Advertisement
Advertisement
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader
Image Preview
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader
Image Preview
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader

Email Sent
We have sent an email to your address "" with instructions to reset your password.