• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

polymorphism

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
What is single polymorphism and multiple polymorphism?
Can somebody explain? Thanks in advance.
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you got me on that one. I'm not sure I've ever heard that terminology before. Maybe it has to do with how a particular method is chosen at runtime based on the specificity of the methods available. For example, if you have something like:

Since a String is an Object, a Comparable and a String, which method is chosen. The answer is the most specific, which in this case is String. Note that by casting to the other reference types we can manage to call the other methods.
 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Multiple polymorphism is a powerful feature, unfortunately not available with standard Java, consider example

if multiple polymorphism would be available, depending on Currency type appropriate method would be invoked, although IBankAccount has only one method declared. With current Java only deposit(Currency curr) is invoked always.
You can look into http://www.cyberdyne-object-sys.com/oofaq2/DynamicDispatch.htm (the above example is taken from their site), I once needed quite badly to have this functionality and stumbled onto this site. They say they've done Java implementation with this feature.
I think Sun could consider this as a future feature.
 
    Bookmark Topic Watch Topic
  • New Topic