how to use finalize()Method to resources

Answer Posted / nidhi

finalize is the method called(if defined) by garbage
collector just before it calls any object for garbage
collection. You are never sure that when will it be called.
The main aim for defining this method is to release the
resources that the object is holding before the object
could be deleted from the memory. If this method is called
then the object is not deleted from the memory in that
particular run of garbage collection but is deleted in the
next run.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why java is call by value?

541


What is the default value of the local variables?

499


What is the use of private static?

526


Can we sort arraylist in java?

555


Which java ide is used the most?

502






Is empty string in java?

533


How do you use find and replace?

501


How to read and write image from a file ?

549


what is mutual exclusion? How can you take care of mutual exclusion using java threads? : Java thread

672


What do you understand by the term wrapper classes?

536


What is high level language in computer?

528


Is java good for beginners?

574


Where and how can you use a private constructor?

528


What are static variables and functions?

617


What is private protected in java?

543