1.

Which among the following is true for constructors overloading?(a) Constructors can’t be overloaded(b) Constructors can be overloaded using different signatures(c) Constructors can be overloaded with same signatures(d) Constructors can be overloaded with different return typesI have been asked this question during an interview.My question is based upon Constructors Overloading in division Default Arguments vs Overloading, Upcasting and Downcasting of Object Oriented Programming

Answer»

Right option is (B) Constructors can be overloaded USING different SIGNATURES

The BEST explanation: The constructors can be overloaded only if the DEFINITIONS have different signatures. Constructors doesn’t have any return type so can’t be overloaded using return type. If constructors have same signature then it will produce a compile time error.



Discussion

No Comment Found

Related InterviewSolutions