Sagot :
Answer:
| Circle9(), System.out.print("C");
| Circle9(double radius), System.out.print("D");
| Circle9(double radius, String color, boolean filled) System.out.print("E");
| GeometricObject(String color, boolean filled) System.out.print("B");
Starting From The Bottom -------------------------------
Explanation:
Just debug it.
But you'll get BEDC due to the code arrangement.
In your main: new Circle9();
So, let's go to Circle9()
-----------------------------------------
public class Circle9 extends GeometricObject {
public Circle9() {
this(1.0);
System.out.print("C");
}
--------------------------------------------------
We need to head to Circle9(double radius) because this(1.0) was called, System.out.print("C"); will not be processed just yet
So, let's go to Circle9(double radius)
-----------------------------------------
public Circle9(double radius) {
this(radius, "white", false);
System.out.print("D");
}
--------------------------------------------------
Again, we need to leave this call and head to another, Circle9(double radius, String color, boolean filled), because of this(radius, "white", false); was called System.out.print("D"); will not be processed just yet
So, let's go to Circle9(double radius, String color, boolean filled)
-----------------------------------------
public Circle9(double radius, String color, boolean filled) {
super(color, filled);
System.out.print("E");
}
--------------------------------------------------
So here super is called which just calls the "parent" GeometricObject(String color, boolean filled).
After that, B is outputted to Console
We then print out E
We then print out D
We then print out C
So.... more concise:
Run Through This Backwards
| Circle9(), System.out.print("C");
| Circle9(double radius), System.out.print("D");
| Circle9(double radius, String color, boolean filled) System.out.print("E");
| GeometricObject(String color, boolean filled) System.out.print("B");
The constructor calls create this chain