What is the difference between polymorphism and Generalization . I saw that they look similar in UML. Are they same ?
2 Answers
Let's look into the Oxford dictionary:
generalization | ˌjen(ə)rələˈzāSH(ə)n |
noun
a general statement or concept obtained by inference from specific cases: he was making sweeping generalizations.
• the action of generalizing: such anecdotes cannot be a basis for generalization.
UML has a graphical representation for that which is a solod line with an open triangle towards the general class.
polymorphism | ˌpälēˈmôrfizəm |
noun
the condition of occurring in several different forms: the complexity and polymorphism of human cognition.
[...]
• Computing a feature of a programming language that allows routines to use variables of different types at different times.
That's a certain use of generalization. If you have, say, an abstract class Animal
which has an operation sound()
and you have different specializations (the opposite of generalization) of that class (e.g. a concrete class Cat
and Dog
) then you can treat the polymorph Animal
by calling sound()
. In case you have a Cat
it would meow and for a Dog
it would bark.

- 35,448
- 8
- 62
- 86
I assume that your question refers to generalization and polymorphism for object oriented programming, for example Java.
Generalization refers to the fact that a class can factorize behaviors and the sub class can benefit from these behaviors. The super class generalizes the behaviors and on the contrary, the sub class specializes these behaviors.
As an object can be seen as the general class or the specialized one (by casting this object), we say that this object is polymorph. At runtime, the polymorphism can influence the choice of the method call: if both super class the specialized one have two implementations of the same method, the program should choose between the two implementations.
Thus, polymorphism is more linked to the fact that at runtime, we have to choose about the nature of the object, whereas generalization is more linked to the concept of inheritance and factorization of behaviors.
You can have a look to these lecture notes for more explanations and examples.

- 1,502
- 14
- 18