import java.awt.*; import java.applet.Applet; public class Shapes extends Applet { public void paint(Graphics g) { Circle circle = new Circle(20, 20); Square square = new Square(80, 80); Shape shape; shape = circle; shape.draw(g); shape = square; shape.draw(g); } } abstract class Shape { int x, y; int size = 20; abstract void draw(Graphics g); } class Circle extends Shape { Circle(int initialX, int initialY) { x = initialX; y = initialY; } public void draw(Graphics g) { g.fillOval(x, y, size, size); } } class Square extends Shape { Square(int initialX, int initialY) { x = initialX; y = initialY; } public void draw(Graphics g) { g.fillRect(x, y, size, size); } }