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

What is the difference between equals() and?

595


What is the benefit of abstract class?

522


What do you mean by multithreaded program?

564


os is developed in c no java is more secured then c na why dont the os developed is developed using java

3531


Why super is first line in java?

566






What is primitive data type in java?

547


How do I convert a string to an int in java?

557


What are the procedures?

612


What if I write static public void instead of public static void in java?

583


Can a java program have 2 main methods?

557


What is lambda programming?

503


What is a qms manual?

550


Write a java program to count the number of words present in a string?

540


How to sort list of list in java?

669


What is a parameter in simple terms?

566