Friday, December 23, 2016

Exception

 Exception

--------------------------------------------------------------------------------------------------------------

Exception is an unexpected event occurred at RUN-TIME provided by the users while entering Dynamic Input, provided by Database Engine while Executing SQL queries in JDBC application, provided by the network while establish connection between local machine and remote machine in
Distributed application.... cause abnormal termination to the application.

In java, there are two types of terminations...
1. Smooth termination
2. abnormal termination

If a program is termination at end of the program, then the termination is called as "Smooth Termination".

If a program is terminated at middle of the program then the termination is called as "Abnormal Termination".

In JAVA application, Abnormal termination may crash to local operating system, it may provide hanged out situation to the network application problem.

To overcome the above problems, we have to handle exceptions properly for this, we have to use a set of mechanisms explicitly called as
"Exception Handling Mechanisms".

JAVA is a Robust Programming language because:
1. JAVA is having very good memory management system in the form of HEAP memory management system, a dynamic memory management System,
it allocates and deallocates memory for the objects at RUNTIME.

2. JAVA is having very good Exception handling mechanism becaue JAVA has provided very good predefined library to represent and handle
almost all the exception which are generated frequetly.

There are two types of Exception in JAVA...
1. Predefined Exception
2. User Defined Exception

1. Predefined Exception :

-------------------------------
These exception are provided by JAVA programming language along with java predefined library.

There are two types of predefined exceptions..
1. Checked Exception
2. Unchecked Exception

Q. What is the difference between pure checked exception and partially checked exception?
----------------------------------------------------------------------------------------------------
Ans. Checked Exception are the exception recognized by the compiler (not occured at compile time) at compilation time.

Unchecked Exception are the exceptions recognized and occured at RUNTIME.
EX: Runtime Exception and its sub classes, Error and its sub classes are the examples for Unchecked Exception and all the remaining exception
classes in the above diaram are examples for checked exception.
---------------------------------------------------------------------------------------------------------

There are two Types of Checked Exceptions:
1. Pure Checked Exception
2. Partially Checked Exception

Q. what is the difference between pure checked exception and partially checked exception?
Ans. if any checked exception contains only checked exception as sub classes then that checked exception is called as Pure Checked Exception.
EX: IOException

If any checked exception contains at least one unchecked exception as subclass then that checked exception is called as Partially Checked Exception.
EX: Excepiton, Throwable

No comments:

Post a Comment