Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exceptions kicking out of program

 
yamini nadella
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to my idea if we catch exceptions then some "fatal" exceptions will terminate the program after catch/finally execution. Some exceptions continue the execution after catching.
Exceptions like Filenotfound etc... are not fatal.execution can continue after catching that exception.
Here what exceptions are fatal and what are not? All Unchecked exceptions and Errors are Fatal?
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yamini,
You can think about exceptions as being one of three types:
  • Errors you expect to happen at some point. You should handle these. Most of the time these will be direct subclasses of Exception, but not RuntimeException, so the compiler will force you to catch or declare these.
  • Errors you know may happen, but don't expect. These are the RuntimeException-subclasses exceptions. You generally don't worry about these unless there are specific instances that you might want to cover (like NumberFormatException) if explicity stated by functions. Sometimes you won't even know what RuntimeExceptions can be thrown by code you call.
  • Lastly, there are the RuntimeErrors that can be thrown. These usually deal with things way out of your control, so you just let them do whatever they want. Examples being running out of memory or other JVM issues.

  • To answer your question though: any unchecked exception that isn't caught and handled by some catch block somewhere will force the JVM to quit with the usual stack trace and chaos.
    [ April 16, 2004: Message edited by: Nathaniel Stoddard ]
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic