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

How can you read an integer value from the keyword when the application is runtime in java? example?

614


What is thread pool? How can we create thread pool in java?

614


Why is singleton instance static?

499


What is the difference between sleep and wait in java?

505


What is void class in java?

517






What is sizeof in java?

550


What is a stack class in java ?

599


What is an empty string in css?

518


What is the differences between c++ and java? Explain

577


Is null == null in java?

641


Can we declare register variable as global?

503


What is the this keyword?

547


Why charat is used in java?

534


What is a boolean expression in java?

524


What is the purpose of format function?

616