Thursday, July 18, 2013

11. What is the significance try and finally without the catch statement in java?

This type of statements are very useful whenever the method containing the try statement throws an exception.

Example:

myMethod throws ArithematicException
{
try{
a=1/0;
}  <--- Observe that there is no catch block
finally{
System.out.println("the above try obviously throws exception");
}
}

No comments :

Post a Comment