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
How to implement an arraylist in java?
What is java beans?
What are the principle concepts of oops?
What is the r character?
What are the advantages of exception handling in java?
A person says that he compiled a java class successfully without even having a main method in it? Is it possible?
What is functional interface in java example?
What does file separator do in java?
what is bmg file and how to create that files?what will it contailn?
In case of inheritance what is the execution order of constructor and destructor?
What is a treeset class?
Variables used in a switch statement can be used with which datatypes?
Which variables are stored in heap?
Can constructor be inherited?
What does jenkins do?