Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using static method in polymorphism

 
Jithesh Kumar
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can a static method can be involved in polymorphism..i mean both static and dynamic polymorphism?
 
Pramod P Deore
Ranch Hand
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, static methods are involved in polymorphism.but only in static polymorhism (i.e static methods can be overloaded) but they are not involved in runtime polymorphism (i.e. static methods can't be overridden).
 
Jithesh Kumar
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no i think static method can be overridden... i tried it but regarding overloading i needed the reply
 
Pramod P Deore
Ranch Hand
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
we can't override static methods, but we can overload static method.
 
Lorand Komaromi
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
bon jith wrote:i think static method can be overridden... i tried it


You can't override a static method, but you can hide it. This article explains the differences between overriding and hiding.
 
Jithesh Kumar
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you give me some example of polymorphism in static overloaded methods?...
 
Muhammad Khojaye
Ranch Hand
Posts: 449
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
bon jith wrote:can you give me some example of polymorphism in static overloaded methods?...

see this FAQ
 
Henry Wong
author
Marshal
Pie
Posts: 20995
76
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be careful with the term "polymorphism". There are lots of definitions out there -- and many are very loose as to include, method overloading, operator overloading, templates / generics, among them.

I would highly recommend that you use the one used by your professor (in your textbooks), or you could wind up failing, because you are using one of those "looser" and not accepted by your professor definitions.

Henry
 
Raj chiru
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
see this Article Static
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic