An exception is an event that may cause abnormal termination of the program during its execution. There are two types of exceptions in java.
1. Checked exceptions
These exceptions are explicitly handled in the code itself with the help of try-ctach block. Checked exceptions are extended java.lang.Exception class
2. Unchecked Exceptions
These are not essentially handled in the program code; instead the JVM handles such exceptions; Unchecked exceptions are extended from java.lang.Runtime exception class
The following is the java exception Hierarchy
The following are the predefined exceptions in Java
- ArithmeticException -Caused by Math errors such as division by zero
- ArrayIndexOutOfBoundException - Caused by bad arrays indexes
- ArrayStoreException - Caused when a program tries to store wrong type of data in an array.
- FileNotFoundException - Caused by an attempt to access non existing file
- IOException - Caused by general I/O failures, such as inability to read from a file
- NullPointerException - Caused by referencing a null object.
- NumberFormatException - Caused when a conversion between string and number fails.
- OutOfMemoryException - Caused when there is not enough memory to allocate a new object.
- SecurityException - Caused when an applet tries to form an action not allowed by the browser security settings.
- StackOverFlowException - Caused when the system runs out of stack space
- IllegalThreadStateException - A thread has be moved illegally from one state to other state.
- ClassNotFoundException - A class cannot be found
- IllegalArgumentException - Illegal arguments used to invoke a method
0 comments :
Post a Comment
Note: only a member of this blog may post a comment.