Nico Van Belle wrote:Off course they will have the same methods, but the bark of a Labrador will not sound the same as the bark of a Chihuahua.
For that, in my example given, you have to cast the Dog objects.
No you don't - that's
exactly what polymorphism is for.
You only need to cast if you have different methods in the subclasses. For instance, your
Dog class might have a
run() method, but your
Greyhound class might also have a
runReallyReallyFast() method. You'll need to cast to get at the extra methods.