This week's book giveaway is in the Raspberry Pi forum.
We're giving away four copies of Getting started with Java on the Raspberry Pi and have Frank DelPorte on-line!
See this thread for details.
Win a copy of Getting started with Java on the Raspberry Pi this week in the Raspberry Pi forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Liutauras Vilda
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Piet Souris

Polymorphism

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
Could someone explain the Polymorphism to me with some examples?
I really want to know the definition of Polymorphism and how we can use it.
Thank you in advance.
Mike
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Def.:
ability of an obj to respond to a message in a
manner appropriate to its type.
Ex: In this example, you could see which method
gets called. The method of the class to which
the object belongs to gets called.

If you are familiar with C++ the same is achieved
using the keyword virtual.
Regds.
- satya
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi mike
polymorphism is a oops concept where function/object act differently according to the situations
for example
add(int a,int b);
add(int a,float b);
add(double d,double x);
see here add function will act differently according to the parametes passed to the add function
this is checked only during runtime. it is taken care by jvm
this in brief polymorphism
hope i am clear if not please get back
regds
thejus/mahesh
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
Polymorphism:One or more object act diferently for same message.
Take one real world example
Suppose one Car (Car Object) , one Cycle (One more object) are running on the road and they reached a signal and with red sign both object will stop.
Here both objects are stopped for one message but the mechanism is different.
I hope it is clear for you.............

Please notice that there are two types of Polymorphism Viz
1) Static Polymorphism and Dynamic Polymorphism or
2) True Polymorphism or False Polymorphism or
4) Compile Polymorphism or Runtime Polymorphism



 
Ruth Stout was famous for gardening naked. Just like this tiny ad:
Low Tech Laboratory
https://www.kickstarter.com/projects/paulwheaton/low-tech-0
reply
    Bookmark Topic Watch Topic
  • New Topic