Sunday, 8 January 2012

Java Concepts: Exception Handling

Exception Handling- Exception handling is a process in which at run-time, JVM exceptionally (by going out of general way), handle a abnormal condition.If we took a simple example- A person is riding a bike at the speed of 100km/hr.Suddenly a cat came in his way and if he is able to handle the accident than it is called exception. but if accident is occur than it is called error.
There are two kind of exceptions:
  1. Checked Exception-The exception which is known to the compiler is called Checked Exception.
  2. Unchecked Exception-The exception which is not known by the compiler is called Unchecked Exception.
SQL Exception , I/O exception are checked exception. Arthematic Exception,Null pointer Exception are unchecked Exception.
  • try-catch block is used for the exception handling.
  • Throw keyword- Throw is used for throwing exception explicitly.generally we use throw keyword for custom exception.Example-throw new ArthematicException();
  • Throws-Throws clause is used as a indicator which is putted in front of a method.It tells the programmer that if you are using this method than you have to care about the given exceptions,they may be arise due to method implementation.

Your mail are welcomed at

No comments:

Post a Comment