Wednesday, 21 May 2014

Exception handling in Java

The exception handling provides the mechanism to handle the runtime errors so that normal flow of the application can be maintained.

Exception

  • Dictionary Meaning:Exception is an abnormal condition.
  • In java, exception is an event that disrupts the normal flow of the program. It is an object which is thrown at runtime.

Exception Handling

Exception Handling is a mechanism to handle runtime errors.

Advantage of Exception Handling

The core advantage of exception handling is that normal flow of the application is maintained. Exception normally disrupts the normal flow of the application that is why we use exception handling.

Five keywords used in Exception handling:

  1. try
  2. catch
  3. finally
  4. throw
  5. throws
 Syntax of try with catch block
  1. try{  
  2. ...  
  3. }catch(Exception_class_Name reference){} 

No comments:

Post a Comment