Problem Statement
What is a constructor in an object-oriented class?
Explanation
A constructor is a special method of a class that is called when a new object is created. Its job is to initialize the new object’s state—setting up fields, allocating resources, or performing setup tasks so that the object is ready to use.
Practice Sets
This question appears in the following practice sets: