Forum

Number Of Page View:100,000+/Months
LOGIN |New User

Reply

What are the ways you can handle exception ?
When an exception is thrown by a method, it must declare or handle it. 
A method can declare the exception using the keyword throws with 
the  method signature and a list of exceptions type so that the 
calling methods can guard themselves. 
For example:
public void myMethod() throws IOException, ArithemeticException{
//some code here that might cause the exception
}

If a method does not declare the exception then it must handle 
the exception by providing the try/catch block.
For example:
public void myMethod(){
try{
//some code here that might cause the arithematic exception
}catch(ArithematicException e){
}
}
Posted By: Name:Rajesh Kr URL: What are the ways you can handle exception ?