what are the differences between final,finally,finalize
methods?
Answer Posted / ravi
A "final" method or variable is one that can't be overridden
- you can define a method as final within a class to ensure
that any extensions to the class don't replace it.
If you add a "finally" block onto the end of a try / catch
exception handler, you're defining a block of code that will
be run if the try is entered, even if problems occur and
your method returns from within a catch rather than continuing.
A "finalize" method is your destructor method - code that's
run to clean up objects that are no longer required. For
example, objects which are memory cached would be flushed
back to the disc in your finalize.
| Is This Answer Correct ? | 8 Yes | 7 No |
Post New Answer View All Answers
What is a finally block? Is there a case when finally will not execute?
Can I declare class as static or private?
Write a program to reverse a number in java?
What is the Concept of Encapsulation in OOPS
what is an objects lock and which objects have locks? : Java thread
What’s meant by anonymous class?
How can we access some class in another class in java?
What are the parts of a method?
What methodology can be employed to locate substrings inside a string?
How do you insert a line break?
Explain jdk, jre and jvm?
What is null in java?
How do I compare two strings in word in java?
what is heap memory?
What is the difference between an if statement and a switch statement?