Explanatory Question
hat is constructor? When is it invoked?
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.
A constructor is a member method that is written with the same name as the class name and is used to initialize the data members or instance variables. A constructor does not have a return type. It is invoked at the time of creating any object of the class.
First read the answer fully, then try to explain it in your own words. After that, open a few related questions and compare the concepts. This method helps you remember the topic for a longer time and improves exam preparation.