Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
5,651

   

The constructor method is a instance method that is automatically called when the class object is created.class_constructor is a static method which is automatically called exactly once before the class is first accessed.

class_constructor is defined with CLASS-METHODS and constructor is defined with METHODS.

 

 

If class is inherited from another class,only superclass can have constructor method.Sub class can not have constructor method.

If class is inherited from another class,superclass as well as subclass can have class_constructor method defined.

 

 

Implementation of main class methods.

 

 

Implementation of sub class methods:

 

Create objects and call methods. 

 

Output: