Unhandled Exception are the exception that are thrown during the execution of program.
Unhandled Exception
Unhandled Exception are the exception that are thrown during the execution of program. These exception are never caught during the execution of program. This result in nasty Exception stack. Usually this type of exception is caught in try and catch block, but this is not possible to catch each and every exception in the program. There are some unavoidable exception that occurs when there is a mistake made by the client rather than it occurred where it is thrown.Eventually,this is userdefined exception that not to be occurred
Unhandled Exception are categorized into different type-
1)Java .lang. Null Pointer Exception-. A java.lang.NullPointer Exception is thrown and not handled by any page.
2)com.jpmc.cig.arch.exception.CIGSystemException-The exception is thrown and not handled by any page flow and message is Application name is not provided by the URL.
3)Java.io.FileNotFoundException-This exception is thrown when a specified file is referred in the program is not found.
4)Java.lang.illegalargument Exception-This exception is thrown when an illegal argument is sent to the method.
Let us Understand the Unhandled Exception with Example
In this code we try to explain example declares an exception class Exception
Check
. The main
method of class Check
invokes
the thrower
method four times, that causes the exceptions to
be thrown three. The main method consists of try statement that try to catches
the exception that the thrower
throws. The thrower
completes normally or abruptly, printed a message describing the status of
code.
class ExceptionCheck extends Exception
{ { super( ); } { super(s); } { { { { catch (Exception e) { { { { } finally { } } |
Output on the Command Prompt
If we pass divide null not test passed as argument to the method ,Command Prompt will show you 0
[thrower("divide") done] C:\saurabh>javac Check.java C:\saurabh java Check "divide" threw a class java.lang.ArithmeticException with message: / by zero [thrower("null") done] Check "null" threw a class java.lang.NullPointerException with message: null [thrower("not") done] Check "not" didn't throw an exception [thrower("check") done] Test "check" threw a class CheckException with message: Test message |