Saturday, March 12, 2011

Introduction to exception

The term exception is shorthand for the phrase "exceptional event". It can be defined as follows:

Definition: An exception is an event that occurs during the execution of a program that disrupts the normal flow of instructions.

Exception is an abnormal condition that arises in the program during execution. When such a condition arises in the program, an appropriate code is written so that it can be handled. It is very much similar to the error codes returned by a subroutine in the C language. Whatever value the function returns can be checked, and depending upon the value you can make out whether it is executed successfully or were there any errors. If there is an error then you need to match the error code with the error list and find out what error occurred. Java runtime environment has adopted this feature extensively using object-oriented methodology in the form of exception handling.
By using the exception handling you can prevent your program from abruptly ending, flashing surprising and annoying error messages. On the contrary, if a minor error crops up it can be handled during runtime and your program resumes from there on without crashing down.

 

Process of Exception handling in java

See next - Types of exception in java

 

No comments:

Post a Comment

Chitika