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 relationship between class and object?
what is the messsage u r going to get from an objectoriented programing?
What is memory leak and how does java handle it?
Where will it be used?
Explain about oops concepts.
How are multiple inheritances done in Java?
Why singleton is not thread safe?
What is encapsulation in java?
How to sort array of 0 and 1 in java?
When do you call copy constructor?
Is nullpointerexception checked or unchecked?
What is stack class in java?
What are use cases?
What is a nested structure?
Explain the public class modifier?