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

What do you mean by buffering?

791


How many java versions are there?

769


What is java ceil?

799


What is the meaning of 3 dots in java?

898


Explain how can you debug the Java code?

842


What is a parameter used for?

747


How many bits is a string in java?

799


How many types of string data types are there?

776


What is boolean query?

768


If an object is garbage collected, can it become reachable again?

792


What does a za z0 9 mean?

765


What is difference overloading and overriding?

823


Is null a string or object in java?

754


Can we call thread start () twice?

723


Explain the difference between abstract class and interface in java?

768