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 considered an anti pattern?
Explain jdk, jre and jvm?
What is the difference between processes and threads?
Is null a value?
What is thread safe java?
What are the different types of garbage collectors in java?
What two classes are used to read data only?
What does microservices mean?
How do you start a new line in java?
Can a static block throw exception?
What is a boolean output?
How will you invoke any external process in java?
What are void pointers?
Can a static member function access member variable of an object?
What is double data type?