Polymorphism_LabTask
Polymorphism_LabTask
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()
Main
In main method create an object reference of Vehicle and then by storing object of Bike and Car
respectively show the polymorphic behavior.