ArrayStoreException
Caused when aprogram tries to store the wrong type
of data in an array.
FileNotFoundException
Caused by an attempt to access a nonexistent file.
5.
IOException
Caused by generalI/O failures, such as inability to
read from a file.
NullPointerException
Caused by referencing a null object.
6.
NumberFormatException
Caused when aconversion between strings and
number fails.
OutOfMemoryException
Caused when there is not enough memory to allocate
a new object.
7.
SecurityException
Caused when anapplet tries to perform an action not
allowed by the browser’s security setting.
StringIndexOutOfBoundsException
Caused when a program attempts to access a
nonexistent character position in a string.
8.
Try
{ ----- //statementsto be monitored for exceptions
-----
}
Catch(ExceptionType1 Exobj)
{ ----- //code for handling the exceptions
-----
}
Finally
{ ----- //contains code that must be executed before returning from method.
----- }
Note:
any number of try-catch can be placed
9.
Try Block
Statement that
Causesan exception
Catch Block
Statement that
handles the exception
Throws
Exception
object
Exception object
creator
Exception
Handler
Fig : Exception handling mechanism: