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?

Can multiple catch blocks be executed for a single try statement?<br/>

Change Image    Delete

Asked by Wyatt Williams, Last updated: Nov 09, 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