Complete the program below to make class Dog declare a constructor that has one (1) parameter and assigns it to the private age | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Complete the program below to make class Dog declare a constructor that has one (1) parameter and assigns it to the private age

class Dog {

25th Oct 2020, 3:10 AM
Hades Name
Hades Name - avatar
4 Answers
+ 2
By seeing your tags, I think here what you want, class dog{ //Here is private field private int age; //Constructor of class dog with a parameter public dog(int age){ this.age=age; } } For more, https://www.sololearn.com/discuss/204290/?ref=app https://www.sololearn.com/discuss/1801634/?ref=app https://www.sololearn.com/discuss/71724/?ref=app https://www.sololearn.com/discuss/1323930/?ref=app
25th Oct 2020, 3:19 AM
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~ - avatar
+ 1
Thanks to you all. Yeah I'm not started any course yet.
25th Oct 2020, 3:23 AM
Hades Name
Hades Name - avatar
+ 1
Don't post homeworks in Q/A. Thank you.
25th Oct 2020, 3:26 AM
🇮🇳Vivek🇮🇳
🇮🇳Vivek🇮🇳 - avatar
- 1
to declare a constructor that has one parameter and assigns it to the age member:
23rd Nov 2021, 6:27 AM
M.Tamilarasi