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

Can anonymous class have constructor?

550


Which eclipse is best for java?

520


Explain listiterator and methods in listiterator?

547


Explain how to force the garbage collection in java.

530


What methods are used in Servlet?Applet communication?

1661






Is there any difference between nested classes and inner classes?

533


What is Recursion Function?

640


Why arraylist is used in java?

547


What is OOP Language?

625


Discuss about garbage collector in Java.

640


What is import java util arraylist?

650


What are the types of strings?

559


Explain the difference between map and flatmap stream operation?

817


How do you sort data in java?

519


Is string is a data type in java?

587