Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exceptions

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There was this mock exam question:
to prevent code which follows a try block from being executed when an exception is caught,you can
a)code a return statement in catch clause
b)call System.exit() in catch clause
c)code a return statement in finally clause
d)code an end clause
e}none of the above.
when i tried an exception program,i found
a)here finally statement is executed but after that nothing is executed.
b)here finally statement is also not executed
c)this results in a compiler error that the statement after finally is unreachable.
d)i have no idea about this end clause.
i would like to know whether the question means none of the statements that follows try should be executed after an exception is caught including finally statement or only statements after finally???
can we include c) as an answer.
please help
thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic