Java Exception Hierarchy / Chapter 2/ Exception Handling

java exception hierarchyJava Exception Hierarchy



  • The Throwable class is the root class for java exception hierarchy.

  • The Throwable class defines two child classes.



  1. Exception

  2. Error


1.Exception:-


Most of the time exceptions are occurs by our java program and these are recoverable.

for example: -


In our java program, there is a requirement of reading data from a remote file which is locating at NewYork (USA). At runtime, if NewYork file is not available our program should not be terminated abnormally and we will get RunTime exception saying"FileNotFoundException". To solve this problem we have to provide some local file to continue rest of the program normally.



try
{
read data from remote file locating at NewYork
}

catch(FileNotFoundException e)
{
use local file & continue rest of the program normally
}

2.Error:-


Most of the time errors are not occurs by our java program and these are due to lack of system resources.Errors are not recoverable.

for example;-

If in a java program OutOfMemory Occurs being a java programmer we can't do anything and the program will be terminated abnormally. System admin, server admin is responsible for increasing the heap memory. 

No comments:

Post a Comment

Be the first to comment!

Don't just read and walk away, Your Feedback Is Always Appreciated. I will try to reply to your queries as soon as time allows.

Note:
1. If your question is unrelated to this article, please use our Facebook Page.
2. Please always make use of your name in the comment box instead of anonymous so that i can respond to you through your name and don't make use of Names such as "Admin" or "ADMIN" if you want your Comment to be published.

Regards,
JavaByChetan
Back To Home

Flipkart End Of Season Sale






© Copyright 2017 Javabychetan.blogspot.com