Types of Exceptions along with examples.pptx

maheswarancs1 0 views 10 slides Mar 25, 2025
Slide 1
Slide 1 of 10
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10

About This Presentation

Introduction to types of Exceptions with example


Slide Content

Some JAVA Exceptions

Some JAVA Exceptions ArithmeticException ArrayIndexOutOfBoundsException ArrayStoreException FileNotFoundException IOException NullPointerException NumberFormatException OutOfMemoryException SecurityException StringIndexOutOfBoundsException

ArithmeticException Caused by math errors such as division by zero ArrayIndexOutOfBoundsException Caused by bad array indexes

ArrayStoreException Caused when a program tries to store the wrong type of data in an array. FileNotFoundException Caused by an attempt to access a nonexistent file.

IOException Caused by general I/O failures, such as inability to read from a file. NullPointerException Caused by referencing a null object.

NumberFormatException Caused when a conversion between strings and number fails. OutOfMemoryException Caused when there is not enough memory to allocate a new object.

SecurityException Caused when an applet 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.

General Format Try { ----- // statements to 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

Try Block Statement that Causes an exception Catch Block Statement that handles the exception Throws Exception object Exception object creator Exception Handler Fig : Exception handling mechanism:

Thank You