2. CONCEPTS OF EXCEPTION
An Exception is runtime error that occur during the
execution of java program.
Error Handling becomes a necessity when develop
applications that need to take care of unexpected
situations.
If u divide by zero or open the file that doesn’t exist,
an exception is raised..
Exception can be handle by run time system or
user defined code.
3. EXCEPTION CLASSES
In Java run time systems searches for an exception
Handler.
In java , a catch statements is an exception handler
is used to handle exceptions.
The search for an exception handler begins with the
method in which exception is raised.
If no appropriate exception handler is found, the
java run-time system searches the exception
Handler in next method hierarchy .
The type of Exception handled by exception
handler should match the type of exception
thrown.
4. The java runtime system proceeds with normal
execution of the program after an exception get
handled.
If no appropriate exception-handler is found by the
java run time system, the program is terminated.
In java Throwable class is the superclass of
exception classes.
Object class is the base class of exception
hierarchy .
The Exception class and the Error class are the two
subclasses of Throwable classes.`
5. OBJECT IS BASE CLAS
Throwable
Exception
ClassNotFoundException
InturruptedException
Error ThreadDeath
8. THROWABLE CLASS
Throwable class is subclass of the object class.
Throwable class is the superclass of all the
exception objects that are derived from throwable
class
We can create constructor of Throwable class
Throwable( ) or Throwable(String Message)
9. EXCEPTION CLASS
The Exception class has various subclasses, such
as
ClassNotFoundException,
IllegalAcessException
and RuntimeException.
When this above exception will fire?
10. ERROR CLASS
Error class define exception related to the java run
time environment.
For example, OutOfMemoryError is an error that
occur when there is insufficient system memory to
execute the program.
A program is abruptly aborted when an error object
is thrown.
Error class throw two constructor.
11. BUILT IN EXCEPTIONS
Checked Exception
Unchecked Exception
Checked Exception are the objects of the Exception
class or any of its subclasses excluding Runtime
Exception classes.
Checked Exception are the invalid condition that
occur in java program due to invalid user input,
network connectivity problem or database problem.
For ex:java.io.IOException is checked exception.
The IOException is thrown whenever i/o operations
is abnormally terminated
12. Exception Cause of Creation
ClassNotFoundException Occurs when the Java run-time
system is unable to find the class
referred
IllegalAccessException Occurs when you want to refer a
class that is not accessible
InstantiationException Occurs when you try to create an
object of an abstract class or
interface
NoSuchMethodException Occurs when you call a method
that does not exist
13. UNCHECKED EXCEPTION
Are the runtime errors that occur because of
programing errors, such as invalid argument
passed to a public method.
The Java compiler does not check the unchecked
exception during program compilation.
For example if you divide a number by zero, a
unchecked or runtime exception is raised
14. Exception Cause of Creation
ArithmeticException Occurs when you make an
arithmetic error, such as dividing a
number by zero
ArrayIndexOutOfBoundsException Occurs when an attempt is made
to access an array elements
beyond the index of the array.
ArrayStoreException Occurs when you assign an
elements to an array that is not
compatible with the data types of
that array
ClassCastException Occurs when you assign a
reference variable of a class to
an incompatible reference variable
of another class
IllegalArgumentException Occurs when you pass an
arguments of incompatible data
types to a method
NegativeArraySizeException Occurs when you create an array
with negative size