• 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
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

java exceptions oca book

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm ending the OCA study guide and reading its chapter number 6 "Exceptions" I don't understand what does it mean when in page 302 it says "In other methods, you will take your callers by surprise by returning a special value. An exception forces the program to deal with them or end with the exception if left unhandled".

So when it says "to deal with them", does it mean that exceptions force the program to deal with the callers (caller = them)?

And about "the exception if left unhandled", this wants to say when it's not possible to continue with the program flow?.
 
Saloon Keeper
Posts: 5718
144
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

So when it says "to deal with them", does it mean that exceptions force the program to deal with the callers (caller = them)?


No. "them" means the exceptions in this context.

And about "the exception if left unhandled", this wants to say when it's not possible to continue with the program flow?.


"unhandled" means the code that calls the method potentially throwing the exception doesn't catch it, but itself throws it - so the exception is propagated further up the method chain.

If you have



You can either not handle the exception like this:



or catch it like this:



Either way, the author of myMethod needs to decide which approach to take, so it's hard to ignore the exception entirely.
 
Pablo Napoli
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim!!!, now it's very clear.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!