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
What is generics in java interview questions?
What is autoboxing and unboxing?
When does a class need a virtual destructor?
Who found java?
Can a main method be declared final?
What is the right data type to represent a price in java?
What is boolean in java?
Do you know how to reverse string in java?
What is parsing a sentence?
Is java se free?
What are inbuilt functions?
What is difference between synchronize and concurrent collection in java?
What does pointer mean?
Does constructor be static?
Why is it called a string?