0% found this document useful (0 votes)
4 views1 page

Java Exception Types Explained

research papers

Uploaded by

RKING
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Java Exception Types Explained

research papers

Uploaded by

RKING
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Types of Exceptions in Java

In Java, exceptions are classified into three main categories:

1. Checked Exceptions:
• Also known as compile-time exceptions.
• These exceptions are checked at compile time, meaning the compiler ensures that these
exceptions are either handled using a try-catch block or declared using the throws
keyword.
• Examples: IOException, SQLException, ClassNotFoundException.

2. Unchecked Exceptions:
• Also known as runtime exceptions.
• These exceptions are not checked at compile time but occur during the execution of the
program.
• These usually result from programming errors such as logical mistakes.
• Examples: NullPointerException, ArrayIndexOutOfBoundsException,
ArithmeticException.

3. Error:
• Represents serious problems that applications should not try to catch.
• Errors usually indicate issues with the Java Virtual Machine (JVM) or hardware problems.
• Examples: StackOverflowError, OutOfMemoryError.

Program for Handling ArrayIndexOutOfBoundsException


The following program demonstrates handling the ArrayIndexOutOfBoundsException
when trying to access an array element beyond its length:

You might also like