You will find here collection of JAVA, J2EE interview questions and answers. This blog includes topics like Core JAVA, Advanced JAVA, RMI, JDBC, JSP, Servlet, EJB, JMS. It has difference, comparison of java concepts. This blog will help freshers as well as experienced people to prepare for java, j2ee interview questions answers.
Friday, February 12, 2010
What is difference between final and finally and finalize?
final:
final keyword can be applied to variables,method,class.
final variable - You can't reassign/modify values to the variables. final class- You cannot extends(inherit) the class.
final method- You cannot override the final methods.
finally:
finally is used in try-catch (i.e exception handling in java).
Each try contain only one finally blocks not more than one.
There is no statement between catch block and try block. It muse execute if exception is occurred or not. Mostly used for memory release (closes connections).
finalize():
This is method used to release the occupied memory.
finalize() method must be protected or public otherwise compile time error.
No comments:
Post a Comment