InterviewSolution
Saved Bookmarks
| 1. |
Which among the following is possible way to overload constructor?(a) Define default constructor, 1 parameter constructor and 2 parameter constructor(b) Define default constructor, zero argument constructor and 1 parameter constructor(c) Define default constructor, and 2 other parameterized constructors with same signature(d) Define 2 default constructorsThe question was posed to me in examination.This key question is from Overloading Constructors in chapter Constructors and Destructors of Object Oriented Programming |
|
Answer» CORRECT answer is (a) DEFINE default constructor, 1 parameter constructor and 2 parameter constructor The explanation: All the constructors DEFINED in a class must have a different signature in order to be overloaded. Here one default and other parameterized constructors are used, wherein one is of only one parameter and other ACCEPTS two. Hence overloading is POSSIBLE. |
|