Home > DeveloperSection > Articles > exception handling in java

exception handling in java


Java Java 
Ratings:
0 Comment(s)
 965  View(s)
Rate this:
Exception handling in java???
before describing technical definition, first of all elaborate what is exception?
Exception stands an event that disrupts the normal flow of the program. It is an object which is thrown at run time.
Technical definition it is an mechanism to handle runtime errors such as classnotfound, SQL, remote etc.

Core Advantage of Exception Handling:
It is to maintain the normal flow of the application. Exception normally disrupts the normal flow of the application that is why we use exception handling.
Let's take an e.g.
  1. statement 1;  
  2. statement 2;  
  3. statement 3;  
  4. statement 4;  
  5. statement 5;//exception occurs  
  6. statement 6;  
  7. statement 7;  
  8. statement 8;  
  9. statement 9;  
  10. statement 10;  
  11. Suppose there is 10 statements in your program and there occurs an exception at statement 5, rest of the code will not be executed i.e. statement 6 to 10 will not run. If we perform exception handling, rest of the statement will be executed. That is why we use exception handling in java.

TYPES OF EXCEPTION:

There are mainly two types of exceptions: checked and unchecked where error is considered as unchecked exception. The sun microsystem says there are three types of exceptions:

Checked Exception

Unchecked Exception

Error.




Don't want to miss updates? Please click the below button!

Follow MindStick