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
How would you format a date in java? I.e. In the ddmmyyy format?
Are constructors methods?
What is the advantage of functional interface in java 8?
How do you sort in java?
Is it correct to say that due to garbage collection feature in java, a java program never goes out of memory?
How do you compare objects in java?
What is java and its types?
Why singleton is not thread safe?
What are the disadvantages of using inner classes?
State some situations where exceptions may arise in java?
How to perform merge sort in java?
Can bool be null?
What is the use of string and stringbuffer?
How is it possible for two string objects with identical values not to be equal under the == operator?
Differentiate jar and war files?