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


Please Help Members By Posting Answers For Below Questions

How would you format a date in java? I.e. In the ddmmyyy format?

759


Are constructors methods?

563


What is the advantage of functional interface in java 8?

511


How do you sort in java?

578


Is it correct to say that due to garbage collection feature in java, a java program never goes out of memory?

566






How do you compare objects in java?

491


What is java and its types?

547


Why singleton is not thread safe?

559


What are the disadvantages of using inner classes?

544


State some situations where exceptions may arise in java?

621


How to perform merge sort in java?

576


Can bool be null?

516


What is the use of string and stringbuffer?

540


How is it possible for two string objects with identical values not to be equal under the == operator?

519


Differentiate jar and war files?

584