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
Is integer a class?
Define how objects are stored in java?
What is the maximum length of a url?
What is an object’s lock and which object’s have locks?
Why do we create public static method in java?
What are the two environment variables that must be set in order to run any java programs?
How do you convert bytes to character in java?
What kind of variables can a class consist?
Is java a super set of javascript?
Can you instantiate the math class in Java?
What classes of exceptions may be thrown by a throw statement?
What is array command?
What does i ++ mean in Java?
What is return type in java?
If you are given the name of the function at run time how will you invoke the function?