Computer Science, asked by kshaishCHABo, 1 year ago

Description of Destructor
What is Destructor?

Answers

Answered by kvnmurty
4
in an OOPS object oriented programming language, objects are defined in classes with properties and methods.

For each class there is a destructor method defined (by default by the compiler/interpreter /system or explicitly by the programmer).  This function/method is executed when an instance of an object is deleted and the memory associate with the object is released.

Answered by CopyThat
2

Explanation:

  • Destructor is a function whose purpose is to deallocate memory space for an  object which was allocated by the constructor. But Java uses a unique automatic  method of deallocation of memory called garbage collection. This happens when  no references to an object exist, that object is assumed to be no longer needed,  and therefore the memory occupied by the object can be reclaimed. Since  garbage collection happens automatically in Java, there is no need of explicitly  defining a destructor function in a class.
Similar questions