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
What language is java written?
Are maps ordered java?
What is a finally block?
What steps are taken when the OS shifts from one-thread execution to another?
How infinite loop is declared?
Write java program to reverse string without using api?
What is the purpose of the enableevents() method?
What is singleton class in ruby?
How do you do a line break in java?
Compare java and python.
What do you understand by a Static Variable?
Explain java code for recursive solution's base case?
What are generic methods?
How does linkedhashmap work in java?
What is gc()?