public class Circle extends Round {
private int radius = 1;
public Circle(int r) {
System.out.println("Circle.Circle() - radius = " + radius);
radius = r;
System.out.println("Circle.Circle() - radius = " + radius);
}
public void draw() {
System.out.println("Circle.draw() - radius = " + radius);
}
public static void main(String[] args) {
new Circle(5);
}
}
class Round {
void draw() {
}
public Round() {
System.out.println("Round() before draw()");
draw();
System.out.println("Round() after draw()");
}
}
Circle.java output
Round() before draw()
Circle.draw() - radius = 0
Round() after draw()
Circle.Circle() - radius = 1
Circle.Circle() - radius = 5
Tag: Study Code Program Java
No comments:
Post a Comment