1.

Which is a good alternative instead of having one zero argument constructor and one single argument constructor with default argument?(a) No constructor defined(b) One default value constructor(c) Defining the default constructor(d) Using one constructor with two argumentsThis question was posed to me by my college professor while I was bunking the class.My doubt is from Constructors Overloading topic in section Default Arguments vs Overloading, Upcasting and Downcasting of Object Oriented Programming

Answer»

Correct ANSWER is (B) One default VALUE constructor

For explanation: The constructor with one default ARGUMENT can be the best alternative. This is because the constructor with one default value will do the WORK for both the default constructor and one argument constructor.



Discussion

No Comment Found

Related InterviewSolutions