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

I want to persist data of objects for later use. What is the best approach to do so?

790


What is strings in java?

777


Why do we need singleton?

715


What is stringreader?

693


Can we serialize static variables in java?

847


Is main an identifier?

740


What are the parts of a method?

723


How big is a pointer?

743


What is void in java?

780


What do you mean by platform independence of Java?

730


Why javac is not recognized?

699


Is it correct to say that due to garbage collection feature in java, a java program never goes out of memory?

785


How does regex work?

713


What is called module?

740


How many types of threads are there in java?

722