Constructors
-Constructors are special member functions used for initialization of user defined data type in multiple forms.-It has same name as class name.
-It get executed automatically/implicitly whenever an object is created.
-Constructor do not have any return type not even void.
Note :
1-If no Constructor are added then Java adds a default Constructor that initializes numeric by 0, boolean by false and character by space.
2-Java does not provide Destructor, rather than Destructor Java provides a utility called as Garbage Collection. After sometimes it run and release unused memory (which has been initialized by NULL).
- Garbage Collection executes periodically.
-If you want your statements to be executed along with "Garbage Collector" you can provide them within
protected void finalize()
-"Garbage Collector" can also be invoked by programmer by calling System.gc();
Well done....Keep it up !
ReplyDelete