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 Answer
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