Site Owners Forums - Webmaster Forums

Site Owners Forums - Webmaster Forums (http://siteownersforums.com/index.php)
-   Programming General (http://siteownersforums.com/forumdisplay.php?f=44)
-   -   What is constructor and destructor in java? (http://siteownersforums.com/showthread.php?t=220247)

Jessicca 04-11-2018 09:15 PM

What is constructor and destructor in java?
 
In Java, constructors are like methods and each object is created by calling a constructor of the class with the new keyword. Some important features of a constructor are: A Constructor must have the same name as the class, They have no return type not even void. A Constructor can be public, private, protected. In Java, there is no destructor. But, Java provides a feature named Garbage collection and it’s an effective way for memory management instead of a destructor. Continue here to get one of the best site providing online dissertation services.

adityadev 03-18-2019 03:34 AM

A Destructor is also a member function of a class, which deallocates the memory allocated to an object. ... Constructor is used to initialize the instance of a class.A constructor in Java is a block of code similar to a method that's called when an instance of an object is created.


All times are GMT -7. The time now is 04:51 PM.


Powered by vBulletin Copyright © 2020 vBulletin Solutions, Inc.