Correct option is C
A
constructor is a special type of method in object-oriented programming that has the
same name as the class. Its primary purpose is to initialize objects of the class when they are created.
Important Key Points:
1. Constructors are automatically invoked when an object is instantiated.
2. They do not have a return type, not even void.
3. Constructors can be
default (no parameters) or
parameterized (accept parameters to initialize fields).
Knowledge Booster:
·
Variable: Can have any valid name and does not need to match the class name.
·
Method: General functions within a class; their names are not required to match the class name.
·
Header File: A separate file in C/C++ containing declarations, unrelated to constructors or class naming.