Answer:
final:
1.Final is a modifier applicable for classes, methods and variables.
If a class declared as final then we can’t extend that class.
i.e. We can’t create child class for that class.
2.If a method is declared as final then we can’t override that method in the
child class.
3.If a variable declared as final then it will become constant and
we can’t perform re-assignment for that variable.
finally:
1.Finally is a block always associated with try catch to maintain
cleanup code
Try {
//risky code
}
Catch(X e) {
//handling code
}
Finally {
//cleanup code
}
finalise():
finalise() is a method which is always invoked by garbage collector
Note:
Finally meant for cleanup activities related to try block,
whereas finalize() meant for cleanup activities related to object just
final:
1.Final is a modifier applicable for classes, methods and variables.
If a class declared as final then we can’t extend that class.
i.e. We can’t create child class for that class.
2.If a method is declared as final then we can’t override that method in the
child class.
3.If a variable declared as final then it will become constant and
we can’t perform re-assignment for that variable.
finally:
1.Finally is a block always associated with try catch to maintain
cleanup code
Try {
//risky code
}
Catch(X e) {
//handling code
}
Finally {
//cleanup code
}
finalise():
finalise() is a method which is always invoked by garbage collector
Note:
Finally meant for cleanup activities related to try block,
whereas finalize() meant for cleanup activities related to object just
before destroying an object to perform cleanup activities.