Exceptions Flashcards
Exception
an exception is an event that alters program flow
Error
Error means something went so horribly wrong that your program should not attempt to recover from it.
RuntimeException
Runtime exceptions tend to be unexpected but not necessarily fatal.
For example, accessing an invalid array index is unexpected.
Runtime exceptions are also known as unchecked exceptions.
Checked exception
A checked exception includes Exception and all subclasses that do not extend RuntimeException.
Runtime Exceptions
ArithmeticException ArrayIndexOutOfBoundsException ClassCastException IllegalArgumentException NullPointerException NumberFormatException
Checked Exceptions
FileNotFoundException
IOException
Errors
ExceptionInInitializerError
StackOverflowError
NoClassDefFoundError
ArithmeticException
Thrown by the JVM when code attempts to divide by zero
ArrayIndexOutOfBoundsException
Thrown by the JVM when code uses an illegal
index to access an array
ClassCastException
Thrown by the JVM when an attempt is made to cast an exception to a subclass of which it is not an instance
IllegalArgumentException
Thrown by the programmer to indicate that a method has been passed an illegal or inappropriate argument
NullPointerException
Thrown by the JVM when there is a null reference where an object is required
NumberFormatException
Thrown by the programmer when an attempt is made to convert a string to a numeric type but the string doesn’t have an appropriate format
FileNotFoundException
Thrown programmatically when code tries to reference a file that does not exist
IOException
Thrown programmatically when there’s a problem reading or writing a file