Explain final, finalize() and finally?
Answer Posted / janet
final: final key word can be used for class,method and
variables.
A final class cannot be subclassed and it prevents other
programmers from subclassing a secure class to invoke
insecure methods.
A final method can't be overridden.
A final variable can't change from it's initialize value.
finalize(): finalize() method is used just before an object
is destroyed and can be called just prior to garbage
collection.
finally: finally, a key word used in exception
handling,creates a block of code that will be executed
after a try//catch block has completed and before the code
following the try//catch block. the finally block will
execute whether or not an exception is thrown.
For example , if a method opens a file upon exit,then
you will not want the code that closes the file to be
bypassed by the exception-handling mechanism. This finally
keyword is designed to address this contingency.
Is This Answer Correct ? | 63 Yes | 4 No |
Post New Answer View All Answers
Can you have two constructors in java?
What is difference overloading and overriding?
Is passing by reference faster?
Explain the difference between abstraction and encapsulation.
describe synchronization in respect to multithreading? : Java thread
What is Session reduplication and how its done?
What are the methods to rectify ambiguities in the interfaces in JAVA?
What are the various access specifiers for java classes?
What is the difference between static method and instance method in Java?
What are three ways in which a thread can enter the waiting state in java programming?
List out benefits of object oriented programming language?
How can we make string upper case or lower case?
What is the size of an array?
What is null statement?
Explain about main thread in java?