File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Dynamic and Static Polymorphism Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Dynamic and Static Polymorphism" Watch "Dynamic and Static Polymorphism" New topic

Dynamic and Static Polymorphism

Raj chiru
Ranch Hand

Joined: Aug 12, 2008
Posts: 141
Is method overloading and method overriding using instance methods are examples of Dynamic polymorphism or Static polymorphism or both?
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 38045
I don't like the term "static polymorphism" and would prefer never to use it.

I think all polymorphism is "dynamic" ("runtime" would be a better word) and that is (in Java™) done entirely with method overriding.
Method overloading is probably not polymorphism at all.

Some people say "static polymorphism" which might better be called "compile-time polymorphism" to mean hiding fields and static methods by declaring fields and static methods with the same name/signature. If you look in books like Effective Java by Bloch or our FAQ (no 16) you can find out how much confusion that can cause.

It may be possible to implement compile-time polymorphism in other languages than Java.
Raj chiru
Ranch Hand

Joined: Aug 12, 2008
Posts: 141
why method overloading is not involved with polymorphism?
Varun Goenka
Ranch Hand

Joined: Mar 09, 2009
Posts: 37
Raj please note this polymorphism is a concept that deals with "same" methods in "different" classes.
Polymorphism is what happens; when you call a method, on a reference; that happens to be of a class that has been extended to another class having that method.

Well.....thats technically correct but lets be frank that sentence will take some time to understand.
But you can always rote learn that sentence and give it to your professor .

From The Demon,
with love.
Varun Goenka
Ranch Hand

Joined: Mar 09, 2009
Posts: 37
Method overloading deals with 2 different methods in the same class, while overriding deals with the same method present in different classes.

Polymorphism deals with the latter.
I agree. Here's the link:
subject: Dynamic and Static Polymorphism
Similar Threads
Compile-time polymorphism?
static polymorphism v/s dynamic polymorphism
using static method in polymorphism