Polymorphism
The last of the four fundamental properties of OOP is polymorphism. Polymorphism
is a property that says all objects must act like all its parent types from which it is inherited. It can also act like other types (e.g., interfaces). In this section, we will discuss only the first part and leave interfaces for another lesson.

Let's take our Shape
class example and build a program with user inputs. In our console program, the user will select a number of different shapes and input the necessary properties of those shapes. Our program will then calculate the total area of all the shapes and output the sum!
The first thing we need for each shape is a method that takes values from the user. Below is the code for it. Notice that we are using an annotation @Override
to override a method. This helps the IDE to identify your mistake if you accidentally create a new method instead of overriding an existing method (e.g. change parameter order or type).
xxxxxxxxxx
}
// Shape.java
public class Shape {
protected int maxWidth;
protected int maxHeight;
// Getters and Setters
public int getMaxWidth() { return maxWidth; }
public int getMaxHeight() { return maxHeight; }
public void setMaxWidth(int maxWidth) { this.maxWidth = maxWidth; }
public void setMaxHeight(int maxHeight) { this.maxHeight = maxHeight; }
public int getMaxArea() { return maxWidth*maxHeight; }
public double getArea() {
return getMaxArea();
}
public void inputFromUser() {
Scanner sc= new Scanner(System.in);
System.out.print("Please input maxHeight :");
this.maxHeight = sc.nextInt();
System.out.print("Please input maxWidth :");
this.maxWidth = sc.nextInt();
System.out.println("Shape input successful");
}
}
// Circle.java
public class Circle extends Shape {
protected int radius;