⭐Constructor


Home SQL Manual Testing Java Selenium

dot_imgDefination:-
>>Constructor is a special method or special member of the class which is used to Initialize Datamember's or Variables.
dot_imgRules
>>Constructor Name should be Same as Class Name.
>>Constructor will not have any return type.
>>Constructor will not return any value.
>>Constructor is always Non-Static.
>>Whenever an object is created Constructor will get invoked(if Instance initialization Block is declared or initialized then first IIb will get excuted and then constructor.)

Syntax Example
class class_name
  {
    class_name()
    _________
    _________
    _________
    return;
  }
class Sample
  {
    Sample()
    _________
    _________
    _________
    return;
  }

dot_imgConstructor are of Two Types
>>1.User-Defined Constructor.
Non-Parameterized and Parameterized
>>2.Default Constructor.