Software Development Fundamentals — Question 34
The purpose of a constructor in a class is to:
Answer options
- A. Initialize an object of that class.
- B. Release the resources that the class holds.
- C. Create a value type.
- D. Inherit from the base class.
Correct answer: A
Explanation
The correct answer is A because a constructor is specifically designed to initialize an object of a class when it is created. Options B, C, and D are incorrect as they refer to resource management, value type generation, and inheritance respectively, which are not the primary functions of a constructor.