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

What is the difference between procedural and object-oriented programs?

530


Do you need to import math in java?

566


What is anti pattern in cyber security?

530


What is method overloading with type promotion?

584


Can a class have multiple constructors?

539






What are parameters in a method?

587


What are the fileinputstream and fileoutputstream?

571


What is use of a abstract variable?

543


Explain 5 features introduced in jdk 1.7?

615


What is field name?

591


What is the difference between assignment and initialization?

565


Can this keyword be used to refer static members?

553


Why char array is favored over string for the storage of passwords?

561


What are streams?

638


What is string builder in java?

560