what are the differences between final,finally,finalize
methods?

Answer Posted / sunil

final variable is a constant.
final method cann't be overrid.
final class cann't be subclassed.

finally is a block usually used to release all the
resources utilized inside the try block such as to free
resources like stream objects, to close sockets .The code
in finally block is guaranteed of execution
irrespective of occurrence of exception catched/uncatched.

finalize() is never run more than once on any object.
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 ?    30 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What class of exceptions are generated by the java run-time system?

920


What do u mean by variable?

829


What is the difference between jdk and jre?

850


Does sprintf allocate memory?

854


Can a lock be acquired on a class in java programming?

754


How do you insert a line break?

708


What are byte codes?

888


Difference between static synchronization vs. Instance synchronization?

853


What kind of variables a class can consist of?

878


What is yield () in java?

696


What is the public method modifier?

781


What are "class access modifiers" in Java?

844


Why is string class considered immutable?

832


What is the purpose of the System class?

796


Write a program to print fibonacci series

833