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

How to check if a list is sorted in java?

590


What is the difference between static (class) method and instance method?

577


How define set in java?

515


What is listnode in java?

537


What is the final keyword denotes?

679






What are the high-level thread states in java programming?

589


What is the meaning of nullable?

580


What is functional interface in javatpoint?

516


What is the effect of keeping a constructor private?

475


What java ide should I use?

572


What is the use of static class?

549


What is the difference between throw and throws keywords?

577


What is fail first in java?

574


What is a newline character in java?

566


Does java trim remove newline?

542