What is the difference between final, finally and finalize ?

What is the difference between final, finally and finalize ?

final is a keyword used for the following things:-

final variable use to prevent the value modification.

final methods can't be inherited.

final class can't be sub-classed.


finally is the block of code used with the try/catch block or the try block if there is no catch associated with the try block.

finalize It is useful where you want some code must be executed whether the exception is thrown or not.finalize is a method that is called by JVM just before the performing the garbage collection.

 But is not sure that this method will be called ore not, it depends upon the JVM.It is declared in the Object class. You can override the finalize() method.


By:Jalees
Date:2012-01-09 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related Java Subjective Links

Java Subjective interview questions and answers for experienced and fresher