final is a keyword used to declare constants. finally block is used in an exception handling.whether there is an exception or not in try block in , finally block will be executed.we used to provide the code like like deallocating resource finalize method will be called by garbage collector to remove the object from memory if it no longer has been used.we can call it explicitely ,but we are not sure that it will remove an object.
o final - declare constant o finally - handles exception o finalize - helps in garbage collection
Variables defined in an interface are implicitly final. A final class can’t be extended i.e., final class may not be subclassed. This is done for security reasons with basic classes like String and Integer. It also allows the compiler to make some optimizations, and makes thread safety a little easier to achieve. A final method can’t be overridden when its class is inherited. You can’t change value of a final variable (is a constant). finalize() method is used just before an object is destroyed and garbage collected. finally, a key word used in exception handling and will be executed whether or not an exception is thrown. For example, closing of open connections is done in the finally method.
Liked By
Write Answer
What is the difference between final, finally and finalize?
Join MindStick Community
You have need login or register for voting of answers or question.
mayur kohli
12-Sep-2017finally block is used in an exception handling.whether there is an exception or not in try block in , finally block will be executed.we used to provide the code like like deallocating resource finalize method will be called by garbage collector to remove the object from memory if it no longer has been used.we can call it explicitely ,but we are not sure that it will remove an object.
Amit Singh
07-May-2011o final - declare constant
o finally - handles exception
o finalize - helps in garbage collection
Variables defined in an interface are implicitly final. A final class can’t be extended i.e., final class may not be subclassed. This is done for security reasons with basic classes like String and Integer. It also allows the compiler to make some optimizations, and makes thread safety a little easier to achieve. A final method can’t be overridden when its class is inherited. You can’t change value of a final variable (is a constant). finalize() method is used just before an object is destroyed and garbage collected. finally, a key word used in exception handling and will be executed whether or not an exception is thrown. For example, closing of open connections is done in the finally method.