The document compares the final, finally, and finalize keywords in Java. Final is a keyword that restricts classes, variables, and methods from being inherited, modified, or overridden. Finally is a block that executes code whether an exception is thrown or not. Finalize is a method that performs cleanup before an object is garbage collected.
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
43 views
Core Java - Final, Finally, Finalize
The document compares the final, finally, and finalize keywords in Java. Final is a keyword that restricts classes, variables, and methods from being inherited, modified, or overridden. Finally is a block that executes code whether an exception is thrown or not. Finalize is a method that performs cleanup before an object is garbage collected.
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1
Difference between final, finally, and finalize
Basis Final Finally Finalize
1. Type It is a keyword. It is a block. It is a method.
The final keyword is used in
Java in order to restrict class, variable, and method. When the final keyword is used in a The finalize method is used class, it restricts the class from The finally block is used in in Java in order to carry out being inherited and it restricts Java in order to execute the cleanup process just 2. Function the variable from being codes whether the exception before the garbage modified in the case in which it has been managed or not. collection operation is run is used with a variable. on an object. Similarly, when the final keyword is used with a method, it restricts the method from being overridden.