Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is 'finally' method in Exceptions?

Answer Posted / sumesh babu r

The finally method will be executed after a try or catch
execution.
It is mainly used to free up resources.
The codes that must be executed, irrespective of whether the
exception is occurred or not, will be included in the
finally block.

See the following simple example to demonstrate the syntax
public class FinallyExample
{

public static void main(String args[])
{

try
{
// the code that may cause an exception
}
catch (Exception e)
{
// the code to be executed, when the exception
occurs
}
finally
{
// code to be executed irrespective of the
occurrence of exception
}
}
}

When using finally, the catch block is not mandatory.
ie, a try block must be followed by a catch or finally block.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the differences between graph and tree?

1162


What is default constructors?

1082


What is the difference between abstraction and encapsulation?

1096


How do you remove spaces in java?

1088


How to connect to a remote database using Applet?

2613


What does it mean that a class or member is final?

1058


What is queue in java?

1226


what is a green thread? : Java thread

1080


Can we call the run() method instead of start()?

1091


is there a separate stack for each thread in java? : Java thread

1034


how to know the total memory occupied by the objects in the ArrayList(Array list may contain duplicate objects)

2393


What is the super void?

956


What is immutable in java?

1135


What is super keyword explain with example?

1356


What are the steps involved to create a bean?

1218