This week's book giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of Succeeding with AI and have Veljko Krunic on-line!
See this thread for details.
Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

Rules Round-up (#132)

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having a problem with this question in the rules round-up game:
TRUE or FALSE: If an exception is not
caught, the finally block will run and the
rest of the method is skipped.
Answer: TRUE
The finally block will always run if an
exception is thrown, and then the exception
is immediately passed to the calling method.
My answer was FALSE. The finally block is executed whether or not an exception is thrown and then the rest of the method is executed, right?
 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its true that if an exception is not
caught, the finally block will run and the
rest of the method is skipped. you can prove it with a simple example.

//after exception line is not executed because of the arthmetic exception thrown at line 5.
 
Ali Macky
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks zarina, that helps. I was thinking that exception was not even thrown...hence why it was not caught.
 
The glass is neither half full or half empty. It is too big. But this tiny ad is just right:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic