Shape
double height
double width
public Shape()
public Shape(…)
public void calculateArea()
Rectangle
public Rectangle()
public Rectangle(…)
public void calculateArea()
Triangle
public Triangle()
public Triangle(…)
public void calculateArea()
Main
In main method create an object reference of Shape and then by storing object of Rectangle and
Triangle respectively show the polymorphic behavior.
2.
Vehicle
String name
int plateNumber
int wheelNumber
public Vehicle()
public Vehicle(name, plateNumber, wheelNumber)
public void start()
public void break()
public void stop()
public void show()
Bike[child class of Vehicle]
String brandName
public Bike()
public Bike(name, plateNumber, wheelNumber,brandName)
/* IT WILL OVERRIDE ALL THE METHODS FROM IT’S PARENT CLASS*/
Car[child class of Vehicle]
String brandName
int seatNumber
public Car()
public Bike(name, plateNumber, wheelNumber,brandName,seatNumber)
/* IT WILL OVERRIDE ALL THE METHODS FROM IT’S PARENT CLASS*/
Main
In main method create an object reference of Vehicle and then by storing object of Bike and Car
respectively show the polymorphic behavior.