Example of Polymorphism

Cylinder à Circle à Point à Shape

 

getArea

getVolume

getName

Shape

0.0

0.0

Abstract

Point

0.0

0.0

“Point”

Circle

πr2

0.0

“Circle”

Cylinder

2πr2 + 2 πrh

πr2h

“Cylinder”

public abstract class Shape extends Object {

public double getArea() {

                return 0.0 }

        public double getVolume() {

                return 0.0 }

        public abstract String getName();

}