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
1 Respuesta
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);
}
}