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

How to stop a thread in java? Explain about sleep () method in a thread?

574


How can we use primitive data types as objects?

550


What is a cup of java?

551


Is array passed by reference in java?

570


How big is a pointer?

544






What do you understand by garbage collection in Java? Can it be forced to run?

543


What is the difference between the paint() and repaint() methods?

577


Explain hashset and its features?

572


Which way a developer should use for creating thread, i.e. Sub classing thread or implementing runnable.

511


What is are packages?

577


Difference between string, string builder, and string buffer?

520


What do you mean by append?

524


If system.exit (0); is written at the end of the try block, will the finally block still execute?

609


What are the two types of exceptions in java? Which are the differences between them?

503


How do generics work?

510