Question 1
Suppose A is an abstract class, B is a concrete subclass of A, and both A and B have a default constructor. Which of the following is correct?
◦ B b = new A();
◦ A a = new A();
◦ A a = new B();
◦ B b = new B();
Question 2
What is the output of running class Test?
public class Test {
public static void main(String[] args) {
}
}
public abstract class GeometricObject {
protected GeometricObject() {
}
protected GeometricObject(String color, boolean filled) {
}
}
public class Circle9 extends GeometricObject {
/** Default constructor */
public Circle9() {
}
/** Construct circle with a specified radius */
public Circle9(double radius) {
| this(radius, "white", false); |
}
/** Construct a circle with specified radius, filled, and color */
public Circle9(double radius, String color, boolean filled) {
}
}
◦ ABCD
◦ BACD
◦ BEDC
◦ CBAE
◦ AEDC