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 similarity between dynamic binding and linking?
What does sprintf mean?
Why chararray() is preferred over string to store the password?
What happens when heap memory is full?
Can we use catch statement for checked exceptions when there is no chance of raising exception in our code?
What is the use of callablestatement?
How to make a read-only class in java?
What exactly is a .class file?
What do you mean by pointer value and address?
Difference between abstract and concrete class ?
what is predefined function in java?
What are the Main functions of Java?
How to check if linked list contains loop in java?
What are the 6 boolean operators?
Can we use different return types for methods when overridden?