 Let's look at the geometric object class again. I've added two methods, get area and get perimeter, to this base class. Both of these methods return zero. Looking at the circle class, I'm overriding those methods. In this case, the perimeter of a circle is its circumference. Here in rectangle, I'm also overriding get area and get perimeter to calculate the area and perimeter of a rectangle. Finally, I have a new class, triangle, which also extends geometric object, and defines the triangle by the lengths of its sides. And here are the methods for calculating its area and perimeter. Now take a look at this test program. I'm going to try this. I'm going to create a geometric object called shape and assign it to be a new circle with a radius of three color blue filled. Let's view our message window and compile this to see if it compiles OK. And it does. Why? Because circle extends a geometric object, anything that's a circle is also a geometric object. This does not work the other way. If I try to say circle C equals new geometric object, the compiler will complain that geometric objects can't be converted to circle. That's because all circles are geometric objects, but not all geometric objects are necessarily circles. Now let's create an array of three geometric objects. Again, all of this is valid because a circle extends geometric object, rectangles are geometric objects, and triangles are geometric objects. I want some code to get the total area of all three shapes. We'll set double total area to zero, and then have a for loop, which goes through the entire array, and say that total area plus and becomes shape sub i dot get area, and then print the result. What do you think will happen when we run this program? You might be thinking that we'll get zero. After all, this is an array of geometric objects, and in geometric object dot Java, we've said that get area returns zero. Let's compile this, and then let's run it, and it turns out we don't get zero. There are really two things that are going on here. Let's look at what happens when the compiler sees the Java code. As far as it's concerned, all the elements of shapes are geometric objects, and that base class has a get area method. That's why the compiler doesn't complain when we say shape sub i dot get area. At runtime, things are different. At runtime, things are different. When the program runs, Java looks at the object that is actually stored in each array element. The first element is truly a circle, so circle's get area method is called. The second element is a rectangle, and rectangles get area method is called. The third element is a triangle, and its get area method is called. That's why the sum of the areas came up to something other than zero. This is called polymorphism, from the Greek words meaning many forms. In Java, polymorphism means that a parent class variable refers to a child class object. At compile time, Java sees variable shape as a geometric object, the parent class. At runtime, Java sees its form as a circle.