How is final different from finally and finalize()?

1 votes
381 views
Anonymous User asked 21-Dec-2017 in Technology by Anonymous User

How is final different from finally and finalize()?

1 Answer

0 votes
Harsh kumar srivastava answered 21-Dec-2017 by Harsh kumar srivastava

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...