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
How to stop a thread in java? Explain about sleep () method in a thread?
How can we use primitive data types as objects?
What is a cup of java?
Is array passed by reference in java?
How big is a pointer?
What do you understand by garbage collection in Java? Can it be forced to run?
What is the difference between the paint() and repaint() methods?
Explain hashset and its features?
Which way a developer should use for creating thread, i.e. Sub classing thread or implementing runnable.
What is are packages?
Difference between string, string builder, and string buffer?
What do you mean by append?
If system.exit (0); is written at the end of the try block, will the finally block still execute?
What are the two types of exceptions in java? Which are the differences between them?
How do generics work?