what are the differences between final,finally,finalize
methods?

Answer Posted / jayakrishnan.p

final is used for making a class no-subclassable, and making
a member variable as a constant which cannot be modified.
finally is usually used to release all the resources
utilized inside the try block. All the resources present in
the finalize method will be garbage collected whenever GC is
called. Though finally and finalize seem to be for a similar
task there is an interesting difference here.This is because
the code in finally block is guaranteed of execution
irrespective of occurrence of exception, while execution of
finalize is not guarenteed.finalize method is called by the
garbage collector on an object when the garbage collector
determines that there are no more references to the object.

Is This Answer Correct ?    168 Yes 17 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is java hashset ordered?

579


Where local and global variables are stored?

549


How is garbage collection controlled?

738


Can you declare a private method as static?

701


What is the method to declare member of a class static?

539






What is a stringbuffer?

517


Does list allow duplicates in java?

522


What is another word for methodology?

521


Why do we declare a class static?

548


What is generic type?

574


What are 4 pillers of object orinted programming?

585


How many bits is a word?

571


What advantage do java's layout managers provide over traditional windowing systems?

551


How do you check if two given string are anagrams?

555


What is bubble sort in java?

621