Java Exception Handling:Unchecked and Checked Exception
What are the various Checked exceptions defined in the java.lang.package and Unchecked RuntimeException subclasses
The built-in exceptions in java are categorized on the basis of whether the exception is handled by the java Compiler or not. Java consists of the following categories of built-in exceptions:
- Checked Exceptions
- Unchecked Exceptions
Checked exceptions are the objects of the Exception class or any of its subclasses excluding the Runtime Exception class. Checked Exceptions are the invalid conditions that occur in a java program due to invalid user input, network connectivity problem or database problems.Java uses the try-catch block to handle the checked exceptions. The statements within a program that throw an exception are placed in the try block. You associate an exception-handler with the try block by providing one or more catch handlers immediately after the try block.
Various checked exceptions defined in the java.lang.package are,
- ClassNotFoundException
- CloneNotSupportedException
- IllegalAccessException
- InstantiationException
- InterruptedException
- NoSuchFieldException
- NoSuchMethodException
Unchecked exceptions
Unchecked exceptions are the run-time errors that occur because of programming errors, such as invalid arguments passed to a public method. The java complier does not check the unchecked exceptions during program compilation.
Various Unchecked Exceptions are,
- ArithmeticException
- ArrayIndexOutOfBoundsException
- ArrayStoreException
- ClassCastException
- IllegalArgumentException
- IllegalMonitorStateException
- IllegalStateException
- IllegalThreadStateException
- IndexOutOfBoundsException
- NegativeArraySizeException
- NullPointerException
- NumberFormatException
- SecurityException
- StringIndexOutOfBounds
- UnsupportedOperationException
No comments :
Post a Comment