1.

If the constructors are overloaded by using the default arguments, which problem may arise?(a) The constructors might have all the same arguments except the default arguments(b) The constructors might have same return type(c) The constructors might have same number of arguments(d) The constructors can’t be overloaded with respect to default argumentsI have been asked this question in an interview for job.My enquiry is from Constructors Overloading in portion Default Arguments vs Overloading, Upcasting and Downcasting of Object Oriented Programming

Answer» RIGHT option is (a) The CONSTRUCTORS might have all the same arguments except the default arguments

The best explanation: The constructors having same arguments except the default arguments can give rise to ERRORS. If only the mandatory arguments are passed, it will create ambiguity in calling the correct CONSTRUCTOR. Hence the mandatory arguments must be different.


Discussion

No Comment Found

Related InterviewSolutions