| Share this post! | Vote this! |
|
All the three keywords final, finally and finalize() plays a very
important role in JAVA. Final is a keyword used for declaration of
variable which cannot be edited, finally is a segment of code used for
code cleanup in case of an exception whereas finalize is a method used
for object cleanup before garbage collection.
Use of final, finally and finalize
Final:- It is used in the following three cases:- If the final keyword is attached to a variable then the variable becomes constant i.e. its value cannot be changed in the program.
- If a method is marked as final then the method cannot be overridden by any other method.
- If a class is marked as final then this class cannot be inherited by any other class. more...




0 comments:
Post a Comment