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

Does google use java?

733


How many types of methods are there in java?

738


What is the difference amongst jvm spec, jvm implementation, jvm runtime ?

707


What is difference between equals and hashcode method?

758


Differece between class and generic class?

771


Write a program to find the whether a number is an Armstrong number or not?

764


What is starvation?

912


What is class array in java?

702


What is the use of runnable interface?

818


What is a war file?

738


What is meant by inheritance and what are its advantages?

816


What is pre increment and post increment in java?

695


What are the uses of synchronized keyword?

735


Is there a jre for java 11?

795


What is difference between array and arraylist in java?

676