You are on page 1of 9

Exception Handling

What is an Exception :

Classification of Errors :

What are the five keywords to handle the exceptions

Classifications of Exceptions in Java


Checked
UnChecked

Exception Propagation
The five Key Words to handle Exceptions in Java

try
catch
finally
throw
throws
Java’s UnChecked Exceptions :

ArithmeticException
ArrayIndexOutOfBoundsException
ArrayStoreException
ClassCastException
NegativeArraySizeExcetption
IllegalArgumentException
NullPointerException
NumberFormatException
SecurityException

Java’s Checked Exceptions

ClassNotFoundException
IllegalAccessException
InstantiationException
InterruptedException
general form

try
{
<Statements>
}
catch(exception type1<parameter1>)
{
<statement>
}
....
...
...
catch(exception typen<parametern>)
{
<statement>
}
finally
{
<statement>
}
--------------------
RuntimeException

---------------
IndexOutofBoundsException
NullPointerException
Exception

ArithmeticException
IOException

FileNotFoundExcep
EOFException
Throwable
Object
Exception Hierarchy :

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

Error
---------------
VirtualMechanicError
Simple try, catch block

How to display Description of Exception


e.printStackTrace()…,
e.toString();
System.out.println(e);
Multiple catch Statements

Nested try, catch blocks

How to call all Exceptions

What is finally block

throw, throws key words

How to throw user defined exceptions


Reflections in java
Modifier() class defined in java.lang.reflect

Methods : static boolean isAbstract()


static boolean isStatic()
static boolean isFinal()
static boolean isInterface()
static boolean isNative()
static boolean isPrivate()
static boolean isPublic()
static boolean isProtected()
static boolean isTransient()
static boolean isSynchronized()
static boolean isVolatile()
Class Methods:

String getName()-> to get Name of the Class


String getSuperClass()
Steps to get Modifier Class :-
1. Get the Class instance Using getClass Method from Object Class

2. Get the int modifer Using getModifers() method from Class ref

3. Use the Modifier class static method to get modifiers

You might also like