Welcome to my blog

I blog my interests and opinions here.

Monday, July 18, 2011

What is polymorphism really!

It's been a while I blogged. With a new baby and things that come with it life kind of has become pretty hectic.

I always thought that polymorphism was the ability to implement the same behavior in different ways. An Animal would move (public void move()) but the way a Cat would implement move would be different from the way an Elephant would implement move. But that is not the case, polymorphism is the forcing the Cat class and Elephant class to implement move() method in their own way by having them implement an IAnimal interface with a public void move(); method. It is inheritance and method implementation that we see here. Method overriding does not mean the classes are exhibiting polymorphic behavior. See the Wiki for more details http://en.wikipedia.org/wiki/Polymorphism_in_object-oriented_programming