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
Java openings 3 - 5 years, Lnt Infotech. requirements - core java, J2ee, struts, hibernate Interview Date:- 19 March 2011 Time:- 9:00 AM to 12:00 Pm Interview Location - L & T Infotech, Manapakkam, Chennai Refererral PS NO:- 291649 (Please mention this when u fill the form only then u will be considered for interview) Documents Required:- Latest Resume, Photograph and last 3 payslips Mail me on vasan2211@gmail.com once u appear for interview
How will you invoke any external process in java?
What does compareto () do in java?
What is split return?
What language is java written?
What is meant by string is immutable?
What is difference between path and classpath in java?
What do you understand by classes in java?
Why java doesn’t support multiple inheritances?
Is string an object?
Is string is a data type?
How to reverse a string in java?
Can a abstract class be declared final?
What is data type example?
In the below example, how many string objects are created?