Explain final, finalize() and finally?

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 ?    4 Yes 11 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the differences between static and dynamic variables?

824


How will you reverse a link list without using recursion?

773


Is set thread safe java?

696


Does variable declaration allocate memory?

776


What are bind parameters?

746


what is instanceof operator used in java?

770


Why are the objects immutable in java?

730


What do you understand by the term singleton?

761


What is foreach loop in java?

738


What is java command?

772


How does map works in java?

727


Implementations of set interface?

763


What does || || mean in math?

690


List out benefits of object oriented programming language?

655


What methods are used to get and set the text label displayed by a button object?

759