1.

Which among the following is true?(a) More than one constructors with all default arguments is allowed(b) More than one constructors with all default arguments can be defined outside the class(c) More than one constructors can be used with same argument list(d) More than one constructors with all default arguments can’t exist in same classThe question was asked in an international level competition.My doubt is from Constructors Overloading topic in section Default Arguments vs Overloading, Upcasting and Downcasting of Object Oriented Programming

Answer» RIGHT choice is (d) More than one constructors with all default arguments can’t EXIST in same class

For EXPLANATION: The constructors must have DIFFERENT ARGUMENT list. Along that, if all the arguments are default arguments, there can’t be more than once constructor like that in the same class as that will create ambiguity while constructors are being called.


Discussion

No Comment Found

Related InterviewSolutions