answersLogoWhite

0


Best Answer

A destructor is exactly the opposite... it gives the object a chance to grab any objects that need to be free'd prior to being freed itself. If care is not taken to "free" objects that have been used but are no longer required this is what is sometimes called a "memory leak". The memory allocated to that object is lost for use. It cannot be re-used for anything else because it is considered "still allocated" even though it is not in use. Generally, this type of program runs out of memory if it is something that runs for days without being restarted.

smartlink4u@hotmail.com

Usama Ikhlaq

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

12y ago

No destructors in Java.

The reason is that all Java objects are heap allocated and garbage collected. Without explicit deallocation (i.e. C++'s delete operator) there is no sensible way to implement real destructors.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is a java destructor?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Why java does not support destructor?

AMIT KUMAR3th Nov , 2014Java does not support destructors, since java supports the concept of garbage collection,hence the garbage collector is used to automatically free the space which has occupied by the program while running.Garbage collector calls the finalize() method which is defined in the object class. finalize() method is called once for each object.


What method in java performs some action (i.e. not assignments) other than returning a value?

Methods that are neither mutators (setters) or accessors (getters). This primarily includes the class constructors (the initialisers) and the class destructor (the restorer).


What is the opposite of inventor?

destructor


What is the difference between the constructor to and destructor?

Functions and Constructors are similar in many ways. They can have arguments, they can have any amount of code, they can access the class's variables etc. the only difference is that a method in java needs to mandatorily have a return type but a Constructor in java cannot have a return type. It always creates and returns an object of the class for which it is the constructor. You cannot return a value from a constructor explicitly and if you try to do that, the compiler will give an error. The system knows that the purpose of the constructor is to create an object of the class and it will do the same irrespective of whether you declare a return type or not.


Can you overload destructor for your class?

No. Classes can only have one destructor, whether you define one yourself or allow the compiler to generate one for you. The compiler-generated destructor is public by default, does not release any memory allocated to any class' member pointers, and is non-virtual, which are the three main reasons for defining your own.

Related questions

Is destructor allowed in java?

No. Java does not support the concept of Destructors like C


How does java support the concept of destructer in java?

In Java, Java does support the concept of destructor, it's done via special method finalize.


What do you use instead of a destructor in java?

Hi, This is suneetha. We use Finalize() method in java instead of destructors. Finalize() is used to release the memory before the garabage collection takes place.


What are destructor in java?

Destructors in Java are called finalizers. Every class can define a finalize() method that will get called automatically by the garbage-collector when an instance of the class gets garbage-collected. Finalizers are not guaranteed to get called, as the instance might never get collected.


Do you have destructer in java?

No. Memory management is handled automatically in Java, so there is no need for a destructor. Also, you can use a finalize block of code where you can assign all large objects to null. This can significantly aid the memory management a.k.a garbage collection done by the JVM.


When was Varroa destructor created?

Varroa destructor was created in 2000.


Why java does not support destructor?

AMIT KUMAR3th Nov , 2014Java does not support destructors, since java supports the concept of garbage collection,hence the garbage collector is used to automatically free the space which has occupied by the program while running.Garbage collector calls the finalize() method which is defined in the object class. finalize() method is called once for each object.


What is l drago destructor ultimate move?

Dragon Emperor Life Destructor.


What method in java performs some action (i.e. not assignments) other than returning a value?

Methods that are neither mutators (setters) or accessors (getters). This primarily includes the class constructors (the initialisers) and the class destructor (the restorer).


What does instructor rhyme with?

Destructor


What is the opposite of inventor?

destructor


What actors and actresses appeared in El destructor - 1985?

The cast of El destructor - 1985 includes: Eduardo Palomo