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


Please Help Members By Posting Answers For Below Questions

Can you have two constructors in java?

487


What is difference overloading and overriding?

571


Is passing by reference faster?

515


Explain the difference between abstraction and encapsulation.

532


describe synchronization in respect to multithreading? : Java thread

491






What is Session reduplication and how its done?

1558


What are the methods to rectify ambiguities in the interfaces in JAVA?

580


What are the various access specifiers for java classes?

537


What is the difference between static method and instance method in Java?

558


What are three ways in which a thread can enter the waiting state in java programming?

674


List out benefits of object oriented programming language?

474


How can we make string upper case or lower case?

591


What is the size of an array?

545


What is null statement?

524


Explain about main thread in java?

604