0

Destructor in Java?

Hey, normally I don't ask questions in here, but I just completed a quiz and there was the question "how many destructors can a class have", since when are there destructors in Java? And how do I implement them? Never heard of that... Thx for reading, have a nice day :D

5th Oct 2020, 11:42 AM
x_gaming
x_gaming - avatar
3 Respuestas
+ 1
Every programming language that follows oop concept and uses classes has destructors
5th Oct 2020, 11:49 AM
Abhay
Abhay - avatar
0
Destructors run when obj of that class is destructor and are optional and only one in no.
5th Oct 2020, 11:50 AM
Abhay
Abhay - avatar
0
Destructor is a method that is opposite to constructor. It's called when an object is destroyed. There's no destructor in Java, but there is finalize() that works as same as a destructor. It's called finalizers. Some website says that finalizers are destructor in Java. Also, unless you need to manage memory manually, you don't really need finalizers because there is Garbage collector to do it for you automatically. https://www.javatpoint.com/java-destructor
5th Oct 2020, 11:53 AM
你知道規則,我也是
你知道規則,我也是 - avatar