What could be in one class contains two constructors or more? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What could be in one class contains two constructors or more?

13th Nov 2016, 6:51 AM
Edbert andoyo
Edbert andoyo - avatar
2 Answers
+ 1
a single class can contain as many constructor you want expect the no of parameter must be different in every constructor. want to know more just search for constructor overloading.
13th Nov 2016, 6:59 AM
Fayeed Pawaskar
Fayeed Pawaskar - avatar
0
Sample (int, double) Sample (int, String) Both can be constructor of Sample class at the same time. The rule you must follow is the difference between parameters
13th Nov 2016, 9:22 AM
Marcell Juhasz