The nice thing with polymorphism is that classes that are otherwise unrelated, can be manipulated through a common interface. And in Java that is taken literally, they must implement a common physical interface, that's why we have to define interfaces in Java. Now when they do implement that common interface, we can treat them polymorphically, here's the example. We have a array of convertible references, so cars is our reference to the array, and then each element of the array is a reference to a convertible. But we're assigning SUV, SportsCar, another SUV, and we're allowed to do that because SUV and SportsCar both is a convertible. So that's just up casting, we can make the assignment, we can loop over the array and we can put the top up on every vehicle, that's not a problem. But let's take that further now, we already have the abstract class car and that has bean properties for name and speed. In some other portion of code, we have a class that we would like to treat in a polymorphic manner, but it does not inherit from car, it isn't a car, it might not even be our code. In consultation with stakeholders, we have defined a new interface Vehicle, that expresses the contract we want, common across all these different types of things. Vehicle will have to bean properties, name and speed. So here is that Vehicle interface, public interface Vehicle and here are the two properties. Remember properties are not defined by attributes, properties are defined by methods. Here is the getName, setName, so there is our name property, here is our speed property. Now in this particular example, we're going to try to incorporate a third party class that has three bean properties of its own, name, RPM and WheelSize. And we're going to pretend we don't even have access to the Train's source code in order to modify it. We're going to create our own subclass of Train that extends Train and implements Vehicle. And by doing that, we'll be able to tie that subclass into our Vehicle hierarchy. We'll also amend CarApp to use Trains as well. So here is the original Train class, you'll notice it's in a completely different package space. And we're going to pretend when we do the demo that we don't even have access to this source code. So public class Train, there's its constructor, takes a name, sets the name and sets a default wheel size of 60, which is in inches, we're assuming a five foot diameter of the driving wheel. There is the getName and setName for the name bean property, there's the RPM bean property, there's the getWheelSize bean property. You'll notice it is publicly readable but is only privately writable for purposes of this exercise. Here is an example of a possible Train subclass to do what we want. It is in our package, and so Train extends the other Train, notice the necessity to fully qualify the class name and implements vehicle. Here is our constructor that calls the parent constructor, and here are the getSpeed and setSpeed bean property implementation, the setter and getter. Basically we're taking the circumference of the wheel, the RPMs, converting it from inches to feet, talking about hours and then dividing to get it into miles per hour. Then in our Vehicle app the old CarApp, we will be able to define a train, we'll modify our loop to be based on Vehicle, because Train is not a car. We'll have all the existing classes plus Train, we'll modify the travelAtSpeedLimit method so that it takes a vehicle not just a car. So that we can simply call that and have it set the speed for everything including our train. Since after all setting speed is a Vehicle interface thing, and whenever possible we code to interfaces, not classes. And then we'll go ahead and print out the vehicles for, again, our demo. And through the use of an interface, we will ensure that that signature, that polymorphic placeholder exists despite having an otherwise disjoint inheritance hierarchy. When vehicle refers to a SportsCar, Java will be calling the SportsCar's implementation of setSpeed. When it's referring to an SUV it'll be calling the Cargo setSpeed, which was inherited by SUV. If the vehicle is a Train, it'll be calling that class' setSpeed, because while the reference type defines what we can say, the class defines what that means. And that is the crucial concept we're trying to get across as we're talking about polymorphism.