Explain final, finalize() and finally?

Answer Posted / zama

final keyword are assigned to 3 different things such as
(1)___to variables:
if the variable is declared as final then value to
that variable can be assigned only once.
(2)___to methods:
if the method is declared as final then method cannot
be overridden.
(3)___to class:
if class is declared as final then class cannot be
inherited.



if finally block is defined in the main() then the stmt
under it will be executed surely,but if the stmt
System.exit(0); is before finally block then it is not executed.



finalize():
finalize() method is called by the Garbage
Collector on an object when there is no more reference to
the object.
finalize() is never run more than once on any object.

Is This Answer Correct ?    5 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do generics work in java?

524


Does list maintain insertion order java?

539


What is better- service oriented or batch oriented solutions?

1537


Why chararray() is preferred over string to store the password?

528


What is bytecode verifier?

506






Can a constructor call the constructor of parent class?

541


Can we synchronize static methods in java?

600


How do you check whether the list is empty or not in java?

515


What is the difference between static (class) method and instance method?

572


Can we overload run() method in java?

599


Define reflection.

575


Is math an abstract class in java?

538


Is binary a low level language?

513


Why Do I Get A "permission Denied" Error After Downloading The .jnlp Java Launcher For The Vkvm?

633


Who is the owner of java?

541