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 the definition of tree ?
Write a regular expression to validate a password. A password must start with an alphabet and followed by alphanumeric characters; its length must be in between 8 to 20.
What is empty list in java?
Do we need to manually write Copy Constructor?
What is the difference between stream and buffer?
What does index mean in java?
Can constructor be inherited?
Is java based on c?
Why do we need singleton?
What does string [] args mean?
What is the difference between Array and Hash Table?
What is an example of a keyword?
What are the practical benefits, if any, of importing a specific class rather than an entire package (e.g. Import java.net.* Versus import java.net.socket)?
What does int [] mean in java?
What is the difference between procedural and object-oriented programs?