Java - Built-in Exceptions


Java defines several exception classes inside the standard package java.lang.

The most general of these exceptions are subclasses of the standard type RuntimeException. Since java.lang is implicitly imported into all Java programs, most exceptions derived from RuntimeException are automatically available.

Java defines several other types of exceptions that relate to its various class libraries. Following is the list of Java Unchecked RuntimeException.

Sr.No. Exception & Description
1

ArithmeticException

Arithmetic error, such as divide-by-zero.

2

ArrayIndexOutOfBoundsException

Array index is out-of-bounds.

3

ArrayStoreException

Assignment to an array element of an incompatible type.

4

ClassCastException

Invalid cast.

5

IllegalArgumentException

Illegal argument used to invoke a method.

6

IllegalMonitorStateException

Illegal monitor operation, such as waiting on an unlocked thread.

7

IllegalStateException

Environment or application is in incorrect state.

8

IllegalThreadStateException

Requested operation not compatible with the current thread state.

9

IndexOutOfBoundsException

Some type of index is out-of-bounds.

10

NegativeArraySizeException

Array created with a negative size.

11

NullPointerException

Invalid use of a null reference.

12

NumberFormatException

Invalid conversion of a string to a numeric format.

13

SecurityException

Attempt to violate security.

14

StringIndexOutOfBounds

Attempt to index outside the bounds of a string.

15

UnsupportedOperationException

An unsupported operation was encountered.

Following is the list of Java Checked Exceptions Defined in java.lang.

Sr.No. Exception & Description
1

ClassNotFoundException

Class not found.

2

CloneNotSupportedException

Attempt to clone an object that does not implement the Cloneable interface.

3

IllegalAccessException

Access to a class is denied.

4

InstantiationException

Attempt to create an object of an abstract class or interface.

5

InterruptedException

One thread has been interrupted by another thread.

6

NoSuchFieldException

A requested field does not exist.

7

NoSuchMethodException

A requested method does not exist.

java_exceptions.htm
Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements