Untitled Document

Subscribe here to get updates on new Videos

 

18. Difference between Exception and Error ?

 

 

 

previous homenext

 

Notes:

1. Throwable acts as root for java exception hierarchy

2. Most of the cases Exceptions are caused by our program and this are recoverable .

Example:

For Example If our program requirement is to read data from a remote file locating at London at runtime if the London file is not available then we will get FileNotFoundException.

If FileNotFoundException occurs then we can provide a local file and rest of the program will be continued normally.

Program:

try
{
Read data from a remote file location at London
}
catch( FileNotFoundException e)
{
use local file & continue rest of the program normally
}

Error:

1. Most of the times errors are not caused by our program these are due to lack of system resources.

2. errors are non recoverable.

Example:

For Example if OutOfMemeory error occurs being a programmer we can’t do anything and the program will be terminated abnormally .

System admin or server admin is responsible to increase heap memory.