Explain final, finalize() and finally?

Answer Posted / tarun

Any class declared by final cannot be subclassed.

Any variable declared with final its value remain constant
that is declared at the time of declaring it.

Any method declared with final in a class can not be
override with other class.

finalize() method is called by the Garbage Collector on an
object when there is no more reference to the object.

finally method is used in exception handling with try-catch
block. try block can not be used alone, it should be used at
least with catch or finally. In catch block we catch(handle)
the exception type that occured during the execution and in
finally we write some code like closing file, connection,
garbag collect any object that is of no more useful in our
application.

Is This Answer Correct ?    7 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the parts of methodology?

734


Given a singly linked list, determine whether it contains a loop or not without using temporary space?

751


What is the use of keywords in java?

757


What is java beans?

760


What is java literals?

767


How dead lock situation occurs in java and how you can identify it?

731


What is singletonlist in java?

699


What is hashtable and explain features of hashtable?

753


You can create a string object as string str = “abc”; why cant a button object be created as button bt = “abc”;? Explain

725


What is serialization in java?

774


How big is a 32 bit integer?

748


What is a protected method?

829


Explain about narrowing conversion in java?

765


How many digits is int32?

717


Can we have multiple classes in a single file?

712