Monday, 11 May 2015

JAVA:Diff bw FINAL,FINALLY AND FINALIZE

final:
1.Final is a keyword applicable for classes,methods and variables
-->When a class declared as a final you cant inherit the class so inheritence is not possible
-->When a method is declared as a final then we cant override that method
-->When a variable declared as a final we cant perform re assignment
2.finally:
-->Finally is a block which is always associates with try catch blocks
-->This block will be executed always whether exception raised or not and wheteher we handled or not.
-->We can use finally block to perform clean up activities like database clocsing connections etc
3.finalize():
-->Finalize() is a method used to perform clean up activities like object destruction
-->Before destroying any useless objects garbage collector calls the finalize method to perform clean up activities
-->Garbage Collector is the assistence of JVM

No comments:

Post a Comment