What is the output of running class Test?
public class Test {
public static void main(String[] args) {
new Circle9();
}
}
public abstract class GeometricObject {
protected GeometricObject() {
System.out.print("A");
}
protected GeometricObject(String color, boolean filled) {
System.out.print("B");
}
}
public class Circle9 extends GeometricObject {
/** No-arg constructor */
public Circle9() {
this(1.0);
System.out.print("C");
}
/** Construct circle with a specified radius */
public Circle9(double radius) {
this(radius, "white", false);
System.out.print("D");
}
/** Construct a circle with specified radius, filled, and color */
public Circle9(double radius, String color, boolean filled) {
super(color, filled);
System.out.print("E");
}
}
任何人都可以在一些细节为什么这个代码的输出是BEDC解释一下吗?这是我正在阅读的一本书的练习题。我不明白。对于我来说,内在是一个很难的话题。需要帮助理解这个代码的输出。
我投票关闭这一问题作为题外话,因为“解释我这一切”不是一个具体的问题陈述。通过手动或调试器来浏览代码,了解多态性是如何工作的,如何更彻底地阅读您的书籍,如果在此之后仍然存在一个非常具体的问题,请发布一个新问题。我们不是在这里解释整个主题。 –