Win a copy of Machine Learning with R: Expert techniques for predictive modeling this week in the Artificial Intelligence and Machine Learning 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

To check my definition (for what i've been reading these days) about polymorphism.

 
Ranch Hand
Posts: 62
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys. This time I'm writting here for once and for all to verify my definition about Polymorphism. I really think that I understand the concept and I know how to apply it, but you know, still I'm not sure if my conclusion about it is 100% right. So let's take a look:

=================================

Polymorphism is the ability of a single interface or object (of a superclass) to take multiple forms.

There are three ways to implement polymorphism (and about these three ways i'm not pretty sure if we can talk about polymorphism):
1- By assigning an object to:
* a reference type that is a superclass of that object.
* an interface type that is implemented by the object

2- By the use of virtual methods what means those methods that are not private, static and final so that they can be overriden and change their behaviour.

3- By the use of "polymorphic parameters" when we have an input parameter that may be both an interface or a superclass so that the method is able to receive an object derived of a subclass or an implementation of the interface.

=================================

So please if you think that some of the definitions are not right or that it would be better to add something else go ahead.

Thanks!
 
Greenhorn
Posts: 16
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

All the definition that you have listed are correct.

You might want to add:

Two Types of polymorphism:
   * Runtime polymorphisms (overriding of functions )
   * Compile time polymorphisms (overloading of functions )

Covariant return types - different return type for a overriding method

Hope this helps.
 
Everybody's invited. Even this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!