what are the differences between final,finally,finalize
methods?

Answer Posted / sunil

final variable is a constant.
final method cann't be overrid.
final class cann't be subclassed.

finally is a block usually used to release all the
resources utilized inside the try block such as to free
resources like stream objects, to close sockets .The code
in finally block is guaranteed of execution
irrespective of occurrence of exception catched/uncatched.

finalize() is never run more than once on any object.
finalize method is called by the garbage collector on an
object when the garbage collector determines that there are
no more references to the object.

Is This Answer Correct ?    30 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are three types of loops in java?

811


Is string is a keyword in java?

749


What do you mean by formatting?

745


Why enumeration is faster than iterator?

720


What is string example?

810


Hi Anyone know the model / questions of the Federal bank sample questions for the post of Specialist Officers - Programmers. Please post if anyone have..

2071


How does finally block differ from finalize() method?

818


How do you sort in java?

783


What is a dot notation?

768


How does a for loop work?

747


What is the inheritance?

742


Write a program to solve producer consumer problem in java?

766


How many bytes is a string?

837


Is simpledateformat safe to use in the multithreaded program?

759


What do you mean by local class?

764