Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

real time example for polymarphism  RSS feed

 
vijay mahendra
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi one and all,

For inheritence there is an real time example like.... Family tree

but i want to know for polymorphism.

please fwd to me anyone.
thanks,
Vijay
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm guessing you meant "real life" instead of "real time". It's tough to apply some OO concepts to things outside software. But since you mentioned a family tree, suppose I have a father and son. I ask the father to put on some music and he plays a 1940's big band CD. I ask the son to put on some music and he plays Green Day. I send them both the same message, they both understand the message, but they do different things in response.

If I ask the dog to put on some music he just tilts his head and looks at me funny. He doesn't understand the message, no polymorphism at work.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!