• 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
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

Polymorphism in java

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How many types of polymorphism are there in java. I don't agree on two types of polymorphism in java. People use to say there are 2 types of polymorphism in java, static(method overloading) and dynamic(method overriding). But ideally there won't be any polymorphism without inheritance. Method overloading can be achieved without inheritance so its not a pholymorphism. Only method overriding is a actual method overriding as it can be done only after inheriting the parent class. Similarly there won't be inheritance without Abstraction. Any comments on this will be appreciated so please give your view on polymorphism in java.

Thanks in advance.

regards
shashi
 
Ranch Hand
Posts: 808
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Overloading isn't polymorphism. Overloading is simply allowing two methods to share a name, as long as they take different parameters. It would be nice if we could at least say about overloading, "it is broadening the definition of behavior X so that it can accommodate different kinds of input". But we can't, because overloaded methods aren't required to be related to each other at all.
 
Marshal
Posts: 72921
330
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
Bartender
Posts: 10777
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Shashibhai Muley wrote:Any comments on this will be appreciated so please give your view on polymorphism in java.


What Dennis said. In fact, the phrase "static polymorphism" seems like an oxymoron to me.

Winston
 
Campbell Ritchie
Marshal
Posts: 72921
330
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Winston Gutkowski wrote:. . . "static polymorphism" seems like an oxymoron to me.

Winston

That’s because it is an oxymoron!
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic