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
I want to persist data of objects for later use. What is the best approach to do so?
What is strings in java?
Why do we need singleton?
What is stringreader?
Can we serialize static variables in java?
Is main an identifier?
What are the parts of a method?
How big is a pointer?
What is void in java?
What do you mean by platform independence of Java?
Why javac is not recognized?
Is it correct to say that due to garbage collection feature in java, a java program never goes out of memory?
How does regex work?
What is called module?
How many types of threads are there in java?