Errors and Exception Types

Error/Exception Description Common Causes
ArithmeticException Thrown when an exceptional arithmetic condition occurs, such as division by zero. Dividing by zero or attempting illegal mathematical operations.
ArrayIndexOutOfBoundsException Thrown when an array is accessed with an illegal index. Accessing an array index that is out of its bounds.
ClassNotFoundException Thrown when an application tries to load a class that is not found. Missing or incorrect classpath or class file missing in the project.
NullPointerException Thrown when the JVM attempts to access a method or field on a null object reference. Dereferencing a null reference or calling methods on null objects.
NumberFormatException Thrown when an attempt is made to convert a string to a numeric type, but the string is not a valid number. Trying to convert a non-numeric string to an integer or other numeric type.
IllegalArgumentException Thrown when a method receives an illegal or inappropriate argument. Passing an argument that doesn’t meet method requirements or constraints.
FileNotFoundException Thrown when an attempt to open the file denoted by a specified pathname fails. Specified file doesn’t exist, or the path is incorrect.
IOException Thrown when an I/O operation fails or is interrupted. File I/O errors, network errors, or improper stream handling.
IndexOutOfBoundsException Thrown when an index of some sort (like for a list or string) is out of range. Attempting to access a list or string index that is outside the valid range.
OutOfMemoryError Thrown when the JVM runs out of memory. Insufficient memory due to large data structures or memory leaks.
StackOverflowError Thrown when the stack of the JVM exceeds its limit. Infinite recursion or too many nested method calls.
NoClassDefFoundError Thrown when a class definition could not be found during runtime. Classpath issues or missing classes at runtime, even though they were available during compilation.
SecurityException Thrown when a security manager denies an access control operation. Security manager prevents access to a restricted resource or operation.
UnsupportedOperationException Thrown to indicate that the requested operation is not supported. Trying to use an unsupported method or operation on a collection or interface.
ConcurrentModificationException Thrown when a collection is modified while it is being iterated over. Modifying a collection while using an iterator.
ClassCastException Thrown when an object is cast to a type of which it is not an instance. Incorrect casting between incompatible types.
TimeoutException Thrown when a blocking operation times out. Network operations or tasks that take longer than expected.
IllegalStateException Thrown when a method is invoked at an illegal or inappropriate time. Calling a method in the wrong state of an object, like calling next() on an empty iterator.
AssertionError Thrown when an assertion fails. assert statement fails.
InterruptedException Thrown when a thread is interrupted while it is waiting, sleeping, or otherwise occupied. When a thread is interrupted during a blocking operation like sleep().
NoSuchMethodException Thrown when a particular method cannot be found. Incorrect method name, argument types, or inaccessible methods due to visibility.
NoSuchFieldException Thrown when a particular field cannot be found. Incorrect field name or inaccessible fields due to visibility.
IllegalAccessException Thrown when an application tries to reflectively access a method or field but doesn’t have access to it. Trying to access a method or field that is private or protected without proper access privileges.
InstantiationException Thrown when an application tries to instantiate an abstract class or an interface. Attempting to instantiate an abstract class or interface.
CloneNotSupportedException Thrown when the clone() method is called on an object that doesn’t implement Cloneable. Attempting to clone an object that doesn’t support cloning.
NegativeArraySizeException Thrown when an attempt is made to create an array with a negative size. Trying to create an array with a size less than zero.
TooManyListenersException Thrown when an attempt is made to add more than one listener to an event source that doesn’t allow it. Adding multiple listeners when only one is allowed.
UnsupportedEncodingException Thrown when a particular character encoding is not supported. Using an unsupported character encoding type in I/O operations.
ResourceException Thrown when a resource fails, such as a network failure. Error in accessing a network or database resource.
MalformedURLException Thrown when a URL is invalid or malformed. Incorrect URL format, such as missing protocol or an invalid URL structure.
SQLException Thrown when there is an error in database access. Database connection failure, syntax error in SQL, or invalid query.
UnsupportedFileSystemException Thrown when an unsupported file system operation is attempted. Trying to use file system operations unsupported by the operating system.
ConnectException Thrown when a connection is refused or fails. Attempting to connect to a service that is unavailable or refuses the connection.
SocketTimeoutException Thrown when a socket connection times out. Connection delay or timeout due to network issues.
UnknownHostException Thrown when the IP address of a host could not be determined. Specified host could not be resolved by DNS.
java.lang.OutOfMemoryError Thrown when the JVM runs out of memory. Memory leaks or insufficient memory allocation for the program.
java.lang.UnsupportedClassVersionError Thrown when a class was compiled with a higher version of Java than the JVM can handle. Class was compiled with a newer Java version than the current runtime environment.