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 the difference between error and an exception?
Is a class subclass of itself?
What is the program development process?
What is the hashcode () and equals () used for?
How can we find the actual size of an object on the heap?
How to print nodes of a Binary tree?
What are the five major types of reference sources?
What is a condition in programming?
What is the different types of functions?
How do you read a char in java?
Why singleton is not thread safe?
What is complexity in java?
What is parsing a sentence?
What are inbuilt functions in java?
When the constructor of a class is invoked?