Constructor is specialized method that is contained in a class. Constructor will be triggered automatically when an object is created. Purpose of the Constructors is to initialize an object of a class.
Constructor’s name is identical to the Class name. Constructors can take parameters but constructors have no return type. This is because; constructors return an object by itself.
Static Constructor
When a constructor of a class is marked with static modifier, then the constructor is called static constructor. Unlike other constructors, Static constructor cannot be triggered while creating instances of that class.
Static constructors will be automatically triggered when the class is loaded for the first time. Static constructors are used to initialize values for the static variables of that class.
Constructor’s name is identical to the Class name. Constructors can take parameters but constructors have no return type. This is because; constructors return an object by itself.
Static Constructor
When a constructor of a class is marked with static modifier, then the constructor is called static constructor. Unlike other constructors, Static constructor cannot be triggered while creating instances of that class.
Static constructors will be automatically triggered when the class is loaded for the first time. Static constructors are used to initialize values for the static variables of that class.
Comments
Post a Comment