Skip to main content

Difference between final, finally, and finalize.

Junior Java
Quick Answer final keyword: makes variable constant, method un-overridable, class un-extendable. finally block: always executes after try-catch, used to release resources (even if exception is thrown - except System.exit()). finalize() method: called by GC before reclaiming object memory - deprecated, unpredictable timing, don't use for cleanup. Use try-with-resources instead of finalize for resource cleanup.

Answer

final: Makes variables constant, classes non-inheritable, methods non-overridable.
finally: Executes after try/catch always.
finalize: Called before garbage collection (deprecated).
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice