Posts tagged polymorphism
Polymorphism basically means that one thing can take many forms, and this is particularly useful for programmers, as it allows us to treat similar types of object in a single manner, yet the objects may actually be slightly different at runtime.
One application of this might be where we have an animal class, we know that the animal class has methods like makeNoise(), move() and eat(), and we can happily develop our application against this. However, we may then like to extend the animal class, and create subclasses like Dog, Fish, and Cat, each which would inherit those methods, and optionally override the implementation to do things that are a little more Dog specific.
This is easily one of the most confusing concepts to a n00b, but to be honest its relatively simple. The most confusing part is that both start with the letter ‘O’. You’ll really need to understand this if you plan to get anywhere as a programmer, as you can bet you’ll be asked “what is the difference between overriding and overloading” during a technical interview.
Heres a brief heads up on what each one means, to get us started :