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

What is the similarity between dynamic binding and linking?

618


What does sprintf mean?

540


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

533


What happens when heap memory is full?

535


Can we use catch statement for checked exceptions when there is no chance of raising exception in our code?

598






What is the use of callablestatement?

582


How to make a read-only class in java?

599


What exactly is a .class file?

581


What do you mean by pointer value and address?

581


Difference between abstract and concrete class ?

586


what is predefined function in java?

548


What are the Main functions of Java?

635


How to check if linked list contains loop in java?

463


What are the 6 boolean operators?

558


Can we use different return types for methods when overridden?

566