The term destructor is used in object-oriented programming ( OOP). It refers to a method that first deletes the attributes of an object and then the object itself. Destructors can also be used to delete, close or release defined resources. For example, to open or delete a connection or a file. Destructors are defined by a tilde character followed by the class name. The opposite mechanism to the destructor is the constructor.