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 does three dots mean in java?
What is the equal sign?
What will happen to the exception object after exception handling?
What does exp mean in math?
Explain when classnotfoundexception will be raised ?
How will you add panel to a frame?
Can there be an abstract method without an abstract class?
What is polymorphism java example?
Difference between ‘is-a’ and ‘has-a’ relationship in java?
What is meant by object?
What are some examples of variable costs?
What is a vector in java?
What is string length in java?
When should I use stringbuffer?
When should we create our own custom exception classes?