Explain difference between final, finally and finalize?
Answer Posted / ranganathkini
When a class is marked final, it cannot be subclassed. When
a method is marked final, it cannot be overridden by the
subclass. And when a field is marked final, its value once
set, cannot be reset.
finally is the last clause in a try...catch block. It is a
block of statements that is executed irrespective if or if
not an exception was caught in the preceding try block.
finalize is a reserved method in Java, which can be
overridden by classes containing code to release any
expensive resources being held to by the object. Expensive
resources include, native peer objects, file/device/database
connections.
Is This Answer Correct ? | 64 Yes | 13 No |
Post New Answer View All Answers
What is an image buffer?
Where is singleton pattern used?
What is the function of http?
What happens if constructor is private?
What is difference between an object and a class?
Explain where variables are created in memory?
Why java is made?
what is nested class in java?
Is 0 an irrational number?
What is an immutable object?
What are the high-level thread states in java programming?
What is return type in java?
What is procedure overloading?
Why is whitespace important?
What is the difference between yielding and sleeping in java programming?