• Post Reply Bookmark Topic Watch Topic
  • New Topic

Polymorphism in java  RSS feed

 
Shashibhai Muley
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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
 
dennis deems
Ranch Hand
Posts: 808
  • Mark post as helpful
  • send pies
  • 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.
 
Campbell Ritchie
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • 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: 56600
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Winston Gutkowski wrote:. . . "static polymorphism" seems like an oxymoron to me.

Winston
That’s because it is an oxymoron!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!