Explain difference between final, finally and finalize?

Answer Posted / vijayakumar chinnnasamy

final:
final keyword can be applied to vairables,method,class.
fianl variable - You can't reassign/modify values to the
vaiables.
final class- You cannt extends(inherit) the class.
final method- You cannt override the final methods.

finally:

finally is used in try-catch (i.e exception handling in
java).
Each try contain only one finally blocks not more than
one.
There is no statement between catch block and try block.
It will be execute if exception is occure or not.
Mostly used for memeory release.

finalize:
This is method used to release the occupied memeory.
finally method must be protected or public otherwise
compile time error.

Is This Answer Correct ?    74 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is java english?

489


What is anagram in java?

512


Which is the class in java?

514


What is the difference between import java.util.date and java .util?

565


What is the difference between notify and notifyall method?

609






Can private members of a base class are inheritable justify?

483


what is the purpose of "virtual"?

564


What is internal variable?

536


If you are given the name of the function at run time how will you invoke the function?

677


Tell us something about an iterator.

544


What happens when I use / and % with a negative numerator?

536


How do you convert an int to a string in java?

539


What about instanceof operator in java?

594


Can we make main() thread as daemon?

572


Justify your answer that you can't define a method inside another method in java, if you can then how?

600