• Post Reply Bookmark Topic Watch Topic
  • New Topic

Rule Round-Up question 68  RSS feed

 
Jon Ferguson
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(#68) If an exception is not caught, the finally block will run and the rest of the message is skipped.

Answer given is true. Well yes but hate to pick but this question does not say an exception is thrown just that its not caught.

If the exception is never thrown then finally will still be called.. but the rest of the message will not be skipped.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12530
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well, i didn't write the questions, or have anything to do with the roundup.

i interpret the question as "if there is an exeption that is not caught".
 
Marilyn de Queiroz
Sheriff
Posts: 9080
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The exact text of question #68 is:
"if an exception is not caught, the finally block will run and the rest of the method is skipped."
I was wondering what sort of message was being skipped when I read the version of the question above.

Perhaps it is not clear that "if an exception is not caught" means "if there is an exception thrown which is not caught" rather than "if no exception is caught(possibly because none was thrown)". In the former case - if an exception is thrown and not caught - then the only thing in the method that will still execute is the finally clause.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Marilyn de Queiroz:
In the former case - if an exception is thrown and not caught - then the only thing in the method that will still execute is the finally clause.


Well, while we are in nitpicking mode, it's actually "finally clause(s)" - it could be more than one, in the case of nested try blocks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!