0

Can a class have multiple constructors?

Can a class have multiple constructors with same no. of arguments? If it's possible how the compiler will identify which constructor to call?

6th Jan 2018, 3:05 PM
Panda
Panda - avatar
3 Answers
+ 2
yes a class can multiple number of constructor
6th Jan 2018, 3:15 PM
᠌᠌Code X
᠌᠌Code X - avatar
0
As long as they have different types so the compiler can tell them apart, yes. You can't use a parent class and it's child as the child also matches the parent.
6th Jan 2018, 3:18 PM
John Wells
John Wells - avatar
0
yes of course a class have many constructors
6th Jan 2018, 4:25 PM
khushi