Throwable Flashcards
FileNotFound
Exception Checked
when trying to access a file that can’t be found.
ArrayIndexOutOfBounds
Exception Runtime
when trying to access out of bounds array index.
IndexOutOfBounds
Exception Runtime (subclass ArrayIndexOutOfBoundsException) - when trying to access out of bounds list (such as arrayList) index
ClassCast
Exception Runtime
when trying to cast an object to an incompatible reference. (see castings notes for more details)
IllegalArgument
Exception Runtime
used when trying to put inappropriate values, but still of the right type, in as method arguments
IllegalState
Exception Runtime
used when trying to modify an object that that is not in appropriate state (e.g. sms text already sent out)
NullPointer
Exception Runtime
when trying to to call a method with a null reference variable.
*local variables are not auto initialized with default values, not even with a null value. trying to work with these unitized variables will lead to compile time problems.
* reaching into the index of an array that is actually null gives nullpointerrefference.
*sending null to toString gives null pointer reference
NumberFormat
Exception Runtime
(subclass IllegalArgumentException) when trying to convert a string to a number that just can’t become a number.
*The method used is IntegerparseInt(String)/IntegerparseInt(String, int base).
* - and + prefixes are fine
* underscores _ in the string values are not okay.
ExceptionInInitializer
Error
(subclass linkage error) - when a static block throws a runtime exception
*can also occur when the initialization of a static variable throws a runtime exception. could be a call to a static method that throws it or the
*static blocks are called when the class loads.
*initilizer blocks are called when an object is created.
StackOverflow
Error (subclass virtual machine error) - when a method calls itself so many times, the jvm runs out of memory. Tis the case when you see a recursive call with no exit condition.
NoClassDefFound
Error (subclass linkage error) when jvm or class loader instance tries to load a class but definition is not found. Sometimes confused with classnotfoundexception which is thrown by class.forName()
OutOfMemory
Error (subclass virtual machine error) - when so many objects are created and used that the heap runs out of memory