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
What is stack class in java?
Why java doesn’t support multiple inheritances?
A person says that he compiled a java class successfully without even having a main method in it? Is it possible?
Can we write any code after throw statement?
What mechanism does java use for memory management?
Can we sort set in java?
Explain what is Marker interface?
How do you clear a list in java?
Why declare Main() method as a static in java ?
What are heap memory and stack memory and what are memory tables.
Which sorting algorithm is in place?
Program to Find the second largest element in an array.
Why is the main method static?
What is the method to declare member of a class static?
How variables are declared?