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...

finalize() method?

Answer Posted / ramanareddy333

every class inherits the finalize() method from
java.lang.Object
the method is called by the garbage collector when it
determines no more references to the object exist
the Object finalize method performs no actions but it may
be overridden by any class
normally it should be overridden to clean-up non-Java
resources ie closing a file
if overridding finalize() it is good programming practice
to use a try-catch-finally statement and to always call
super.finalize() (JPL pg 47-48). This is a saftey measure
to ensure you do not inadvertently miss closing a resource
used by the objects calling class
protected void finalize() throws Throwable {
try {
close(); // close open files
} finally {
super.finalize();
}
}

any exception thrown by finalize() during garbage
collection halts the finalization but is otherwise ignored
finalize() is never run more than once on any object

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can a static block throw exception?

1138


Is null in java?

1079


Define locale.

1096


What is native method in java?

1121


How many types of exception can occur in a java program?

1039


What is casting in java programming?

1086


What are the advantages of exception handling?

1118


which is advanced deep technology in java launched by the sun microsystem??? The answer is very logical If u need correct answer mail me at priya_gupta@gmail.com

3713


How will you call an Applet using Java Script Function?

1088


What is lexicographically smallest string?

1131


What happens if a try-catch-finally statement does not have a catch clause to handle an exception that is thrown within the body of the try statement?

1173


what is the difference between a threads start() and run() methods? : Java thread

1061


Explain a situation where finally block will not be executed?

1092


How can we access some class in another class in java?

1053


Which class is the superclass for every class in java programming?

1063