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
What is the benefit of using enum to declare a constant?
Why use string handling in Java?
What does compareto () do in java?
Hi Anyone know the model / questions of the Federal bank sample questions for the post of Specialist Officers - Programmers. Please post if anyone have..
what is deadlock? : Java thread
How do you find the independent variable?
How do you sort an array in java?
What are disadvantages of java?
When is the finalize() called? What is the purpose of finalization?
Why do we use string?
Can inner class final?
Where are local variables stored?
Is string thread safe in java?
what is the final keyword denotes in java?
make a method which any number and any type of argument and print sum of that arguments.....