Why finalize method in object class is protected ?

Showing Answers 1 - 2 of 2 Answers

ravi_1229

  • Mar 24th, 2008
 

every user defined class extends object class in java . so  if the user defined class having some resources to deallocate(such as database connection, file closing, streams closing) the finalize method is overriden in the current class. thats y the finalize method in object class is protected.

  Was this answer useful?  Yes

vimalraj

  • Mar 24th, 2008
 

The fact that class Object declares a finalize method means that the finalize method for any class can always invoke the finalize method for its superclass. This should always be done, unless it is the programmer's intent to nullify the actions of the finalizer in the superclass. (Unlike constructors, finalizers do not automatically invoke the finalizer for the superclass; such an invocation must be coded explicitly.)

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions