As you say, overriding. Overloading isn't polymorphism becase the overloaded methods are in the same class as each other. You will doubtless have heard the Design Patterns chaps' mantra
Favour composition over inheritance.
You can use something like this:- Engine<-----------------Car ^ DieselEngine OttoEngine WankelEngine
As you know, Diesel Otto and Wankel were three German chaps who invented the engines which bear their name, Otto being the 4-stroke petrol (gas) engine and Wankel the rotary petrol (gas) engine. Now you can have different behaviours for each type of engine.
Now, you can have such silly code for any different kind of engine, in which case you are using polymorphism at the Car level, but it is actually polymorphism at the Engine level. You can have the same for class MotorBicycle; motor cycles use Otto engines, or two-stroke engines. I am not sure whether you actually call it polymorphism in these circumstance.
I tried editing the original post and bits went missing, so I have tried to reconstruct what I meant to say originally. [ June 02, 2006: Message edited by: Campbell Ritchie ]
Some people -- and I am definitely not one of them -- like to call method overloading "static polymorphism" or "compile-time polymorphism", and overriding "dynamic polymorphism" or "runtime polymorphism". So a person asking you "how many kinds are there?" either wants to hear two or one.
Personally I dislike the idea, and prefer to think of polymorphism as referring only to runtime polymorphism.
I used to enjoy "polymorphism by coincidence" in VB4. There was no inheritance but you could try to call a method on any object. If it worked, hey, polymorphism! If not you handle the error and go on your way. So throw that in your answer and see what they say.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
author and iconoclast