1.

Why do we use constructor overloading?(a) To use different types of constructors(b) Because it’s a feature provided(c) To initialize the object in different ways(d) To differentiate one constructor from anotherThe question was asked in an online interview.My doubt stems from Overloading Constructors topic in chapter Constructors and Destructors of Object Oriented Programming

Answer»

Right choice is (c) To INITIALIZE the object in DIFFERENT ways

Explanation: The constructors are overloaded to initialize the objects of a class in different ways. This allows us to initialize the object with either default values or used given values. If data members are not initialized then program may give UNEXPECTED RESULTS.



Discussion

No Comment Found

Related InterviewSolutions