0

Complete the code segment to call default constructor first and then any other constructor in the class.

I did this program. Please tell me the correct way to solve this. If the code above the comment should not be changed. https://code.sololearn.com/cuPWiUjDNGr8/?ref=app

29th Sep 2020, 7:18 PM
Atul Gautam
Atul Gautam - avatar
1 Odpowiedź
0
Use this(); in the first line of the parametrized constructor and it will call your default constructor. class Answer{ Answer(){ System.out.println("You got nothing."); } Answer(int marks, String type){ this(); System.out.println("You got "+marks+" for an "+ type); } }
29th Sep 2020, 7:28 PM
Антонио
Антонио - avatar