Understanding the Exception Handling
In this lesson we’re going to discuss about overview of exception handling. Let’s begin our discussion by knowing what is meant by exception. In Java exceptions are objects that define an abnormal condition that interrupts the normal flow of a program. The term exception refers to the era.
In Java areas are identified during compile time and run times, compile time errors are basic syntax areas whereas run time eras are exceptional. Class exception is derived from their base class throwable. Throwable serves as the base class for a whole family of the classes declared in the Java.lang. Let’s see a hierarchy to know how exception is derived.
Here class throwable has two direct subclasses, exception and error. Then exception is separated into many subclasses like interrupted exception and run time exception etcetera. Then run time exception contains lots of subclasses similarly class error contain subclasses like thread death and linkage error etcetera.
Now let’s see the types of exception. Generally, exceptions are separated into two types. They are unchecked exceptions and checked exceptions. First, let’s discuss unchecked exception. Unchecked exceptions must extend the run time exception class or arithmetic exception class or null point to exception class.
Unchecked exceptions can occur anywhere in the program but not compulsorily. But exceptions which extend the run time exception class are called unchecked exceptions. Now let’s discuss checked exceptions. Checked exceptions are exceptions that don’t extend the run time exception class. Checked exceptions are used to avoid a compile time error.
For example I owe exception is a checked exception or the other exceptions belong to unchecked exceptions. Now let’s discuss about exception handling. Exception handling is a mechanism the handling exceptions by detecting and responding to exceptions in the uniform and reliable manner. In Java this is known as catching an exception. This can be achieved via five keywords try, catch, throw, throws and finally each block has methods to perform their own function.
In the upcoming lessons, you we will discuss about it in detail. In Java there are plenty of exceptions available but now let’s have a look at some important to Java exceptions.
Here are some advantages of exception handling in Java. First one is separating error handling code from regular code and next propagating errors of the cool stack then grouping error types and error differentiation. For more information please refer to this link.
Transcription by:
Scribe4you Transcription Services