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
Why is the type for real numbers called double?
Why there are some null interface in java? What does it mean?
What is length in java?
Can Exception handling we can handle multiple catch blocks?
What is a get method?
What is complexity and its types?
What’s the difference between unit, integration and functional testing?
What is the static keyword?
How do I get the | symbol on my keyboard?
What do you mean by thread safe?
what is abstract class in Java?
How do you use substring in java?
What are the difference between string, string builder, and string buffer in java?
Can we sort hashset in java?
What are the string methods in java?