Example of Polymorphism
public
class Point extends Shape
//override abstract method getName to return “Point”
public String getName()
return “Point”;
public String toString() {
return getX() “+” getY();
public
class Circle extends Point {
private double radius;
…constructor, set/get radius, diameter, etc..
public double getArea()
return Math.PI * getRadius()*getRadius;
public String getName()
return “Circle”