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
Is java hashset ordered?
Where local and global variables are stored?
How is garbage collection controlled?
Can you declare a private method as static?
What is the method to declare member of a class static?
What is a stringbuffer?
Does list allow duplicates in java?
What is another word for methodology?
Why do we declare a class static?
What is generic type?
What are 4 pillers of object orinted programming?
How many bits is a word?
What advantage do java's layout managers provide over traditional windowing systems?
How do you check if two given string are anagrams?
What is bubble sort in java?