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
Who is the owner of java?
What is callablestatement? How you can call stored procedure to pass in parameter?
What is a method in programming?
What does the exclamation mark mean in java?
What are the drawbacks of reflection?
What is diamond operator in java?
Difference between stack and queue?
What is a linkedhashmap java?
What is difference between static and final?
Can java program run without jre?
Lowest Common ancestor in a Binary Search Tree and Binary Tree.
What is thread safe in java?
What an i/o filter in java programming?
Give few examples of final classes defined in Java API?
What is unmodifiable collection in java?