• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exceptions

 
josephine chen
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic