Alright let’s see.
First you call Circle9()
that starts the constructor:
/** No-arg constructor */
public Circle9() {
this(1.0);
System.out.print("C");
}
As you can see the constructor first calls this(1.0)
This means that another constructor is opened and afterwards we print “C”
Alright the next Constructor is:
public Circle9(double radius) {
this(radius, "white", false);
System.out.print("D");
}
The same thing happens, first another constructor is called with this, and then D is printed
The next called constructor is:
public Circle9(double radius, String color, boolean filled) {
super(color, filled);
System.out.print("E");
}
This calls a super constructor. Since Circle9 extends GeometricObject it can use GeometricObject functions. So super(color,filled)
calls
protected GeometricObject(String color, boolean filled) {
System.out.print("B");
}
And prints B, then E from before, then D and lastly C
output should be BEDC
1
solved Need help understanding the output of this code. [closed]