class B {
private int radius = 10;
public void draw() {
System.out.println(“B.draw(), radius = ” + radius);
}
public B() {
System.out.println(“B constructor”);
draw();
}
}
public class A extends B {
private int radius = 1;
public void draw() {
System.out.println(“A.draw(), radius = ” + radius);
}
public A(int radius) {
this.radius = radius;
System.out.println(“A constructor”);
}
public static void main(String[] args) {
A a = new A(5);
}
}
|
|