This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Exceptions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Exceptions" Watch "Exceptions" New topic
Author

Exceptions

josephine chen
Ranch Hand

Joined: Oct 29, 2002
Posts: 216
Check my answer
To prevent code which follows a try block from being executed when an exception is caught, you can:
does this mean statements under tryblk --finally or other
statements or both???

a) Code an end clause. //f

b) Code a return statement in the finally clause. //u cannot have statements underneath this compiler gives error

c) Code a return statement in the catch clause.
//excutes finally but not statements underneath

d) Call System.exit() in the catch clause.
//does not execute finally


Sridhar Garimella
Ranch Hand

Joined: Feb 18, 2000
Posts: 73
Check my answer
To prevent code which follows a try block from being executed when an exception is caught, you can:
does this mean statements under tryblk --finally or other
statements or both???
a) Code an end clause. //f
b) Code a return statement in the finally clause. //u cannot have statements underneath this compiler gives error
c) Code a return statement in the catch clause.
//excutes finally but not statements underneath
d) Call System.exit() in the catch clause.
//does not execute finally
I think with respect to this situation c and d are correct.Because finally is a optional one.So, there is no problem
if finally is not present.I think the context of this question is finally is not present.Then straight the asnwers are c and d


Thanks,<br />Sridhar.
 
 
subject: Exceptions
 
Similar Threads
try catch block
Exceptions
exceptions
try/catch question
Finally abrupt return