Constructor
- Constructor is special type of methods whose name is constructor.
- Constructors are executes automatically when object of the class is created.
- Always Constructor’s visibility is public.
- 2 types.
- Instance constructor.
- Static constructor.
- Instance constructor called automatically when object is created.
- Instance constructor can be called as per number of objects are created.
- Instance constructor can be called method name "CONSTRUCTOR".
- An instance constructor can have IMPORTING parameters and exceptions. You must pass all non-optional parameters when creating an object.
- Static constructor can be called only once when class has been loaded.
- Static constructor has 1st priority than Instance Constructor.
- Static constructor can be called method name " CLASS_CONSTRUCTOR".
- Static constructors have no parameters.
Comments
Post a Comment