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

Explain about arraylist?

1089


Can constructor be inherited?

1030


What's a method in programming?

1065


What is literal example?

940


What is difference between jdk,jre and jvm?

1116


Outline the major features of java.

1074


Which oo concept is achieved by using overloading and overriding?

1002


Explain the difference between comparator and comparable in java?

939


Which one of the following suits the description of a string better: derived or primitive?

946


how to write a program for sending mails between client and server

2068


How is it possible for two string objects with identical values not to be equal under the == operator?

980


How do you make a thread in java?

1086


What do you mean by flow of struts?

1304


When does an object becomes eligible for garbage collection in java?

1055


Why is it called buffering?

1113