adspace


Explain final, finalize() and finally?

Answer Posted / tarun

Any class declared by final cannot be subclassed.

Any variable declared with final its value remain constant
that is declared at the time of declaring it.

Any method declared with final in a class can not be
override with other class.

finalize() method is called by the Garbage Collector on an
object when there is no more reference to the object.

finally method is used in exception handling with try-catch
block. try block can not be used alone, it should be used at
least with catch or finally. In catch block we catch(handle)
the exception type that occured during the execution and in
finally we write some code like closing file, connection,
garbag collect any object that is of no more useful in our
application.

Is This Answer Correct ?    7 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a program to print count of empty strings in java 8?

1091


explain different ways of using thread? : Java thread

1087


What is the difference between equals() and == in java?

1046


How to sort array in descending order in java?

999


Write a program to find the whether a number is an Armstrong number or not?

1106


What are the differences between heap and stack memory in java?

1150


Realized?

2269


What is java string pool?

1088


What is a classloader in java?

1092


How to create a base64 decoder in java8?

1144


Is minecraft 1.15 out?

1049


What is a constructor overloading in java?

1130


Differentiate between static and non-static methods in java.

1131


What is an object in java and how is it created?

1146


What is the difference between break and continue statements?

1131