Exception:
1)A set of statement that distrub the flow of program
2)It can be fixed
3)It has a two types
*Checked exception:
1)JDK will identify the exception at compile time
*unchecked exception:
1)it will identify the exception at runtime time
2)It can be handle by try block and catch block
try block:
1)It is to monitor the set of statement inside the block that might could throws an exception
Syntax:
try
{
statement;
}
catch block:
1)It is to handle the exception of statements,where the exception is throw by the try block
syntax:
catch(exception referance name)
{
Statement;
}
throw:
1)It is a keyword,to handle the exception for a statement in a method
2)It is used to handle a particular exception in a method
3)Syntax: throw new Exception("Message");
throws:
1)It is to declare a exception at method signature, it might throw an exception
EX: void devide() throws exception
{
}
2)And,the exception is handeld by the caller
3)while declare the exception,it will force to handle the exception(turned to checked exception) by try,catch block
Top comments (0)