How is final different from finally and finalize()?

Asked 21-Dec-2017
Viewed 765 times

1 Answer


0

Hi Sara,

Now we go to a short description of Final, Finally and Finalize(),

In Java, final is a modifier which can be applied to a class or a method or variable. It can't be inherited and overridden and also when we declare a variable by using the final word, it's valued can't be changed.

finally is executed whether an exception is raised or not by the try block code segment. Or in other words finally is an exception handling block which gets executed whether an exception is raised or not by the try block code segment.

And the last one is, finalize(), it's a method of object class which will be executed by the JVM just before garbage collecting object to give a final chance for resource releasing activity.

Hope it's informative for you...