Polymorphism is the ability of an object to assume multiple forms. The example below assumes a class heirarchy with Appender as the superclass. For now it is sufficient to know that the Appender class is responsible for appending log statements to a certain destination. This class has three subclasses, ConsoleAppender, FileAppender, and DatabaseAppender, each of which implement the 'append' of the superclass to direct the log statement to the console, file, and database respectively. The audio explains polymorphism with this simple example.
[Time: 3 mins 40 secs]
Watch a simple animation of how Polymorphism works.
Discuss this post in the learning forum.
Note: This text was originally posted on my earlier blog at http://www.adaptivelearningonline.net
- Buy programming books from our Amazon.com powered storefront.
- Earn as you browse. Sign up for Algoco.