Skip to main content
deleted 7 characters in body
Source Link
Doc Brown
  • 220.5k
  • 35
  • 410
  • 625

You are confused because you think of inheritance and polymorphism as separate concepts. But in fact, inheritance is one possible way of implementing polymorphism, which makes the latter the more general concept, and inheritance a special form of the former.

So yes, as you wrote (and as also stated in the article you linked to), every object of every class in Java or C# is polymorphic, since it they all derive from Object. And yes, "as soon as a class inherits from another class, it becomes polymorphic" - that's correct. However, the "opposite" is not mandatory: when objects are polymorphic, that does not necessarily mean there is inheritance involved.

This is probably easier to understand when you have seen examples of polymorphism without inheritance, like Microsoft's component technology COM, which does not even implement inheritance. For example, using late binding for COM components, it is possible to implement something like a strategyuse objects in a polymorphic way without a common base class or an explicitly defined common interface, but with different "strategy" objects. Another example is "static polymorphism" in C++ template meta programming, or polymorphic functions in Python, like shown here.

You are confused because you think of inheritance and polymorphism as separate concepts. But in fact, inheritance is one possible way of implementing polymorphism, which makes the latter the more general concept, and inheritance a special form of the former.

So yes, as you wrote (and as also stated in the article you linked to), every object of every class in Java or C# is polymorphic, since it they all derive from Object. And yes, "as soon as a class inherits from another class, it becomes polymorphic" - that's correct. However, the "opposite" is not mandatory: when objects are polymorphic, that does not necessarily mean there is inheritance involved.

This is probably easier to understand when you have seen examples of polymorphism without inheritance, like Microsoft's component technology COM. For example, using late binding for COM components, it is possible to implement something like a strategy objects without a common base class or an explicitly defined common interface, but with different "strategy" objects. Another example is "static polymorphism" in C++ template meta programming, or polymorphic functions in Python, like shown here.

You are confused because you think of inheritance and polymorphism as separate concepts. But in fact, inheritance is one possible way of implementing polymorphism, which makes the latter the more general concept, and inheritance a special form of the former.

So yes, as you wrote (and as also stated in the article you linked to), every object of every class in Java or C# is polymorphic, since it they all derive from Object. And yes, "as soon as a class inherits from another class, it becomes polymorphic" - that's correct. However, the "opposite" is not mandatory: when objects are polymorphic, that does not necessarily mean there is inheritance involved.

This is probably easier to understand when you have seen examples of polymorphism without inheritance, like Microsoft's component technology COM, which does not even implement inheritance. For example, using late binding for COM components, it is possible to use objects in a polymorphic way without a common base class or an explicitly defined common interface. Another example is "static polymorphism" in C++ template meta programming, or polymorphic functions in Python, like shown here.

added 152 characters in body
Source Link
Doc Brown
  • 220.5k
  • 35
  • 410
  • 625

You are confused because you think of inheritance and polymorphism as separate concepts. But in fact, inheritance is one possible way of implementing polymorphism, which makes the latter the more general concept, and inheritance a special form of the former.

So yes, as you wrote (and as also stated in the article you linked to), every object of every class in Java or C# is polymorphic, since it they all derive from Object. And yes, "as soon as a class inherits from another class, it becomes polymorphic" - that's correct. However, the "opposite" is not mandatory: when objects are polymorphic, that does not necessarily mean there is inheritance involved.

This is probably easier to understand when you have seen examples of polymorphism without inheritance, like Microsoft's component technology COM. For example, using late binding for COM components, it is possible to implement something like a strategy objects without a common base class or an explicitly defined common interface, but with different "strategy" objects. Another example is "static polymorphism" in C++ template meta programming, or polymorphic functions in Python, like shown here.

You are confused because you think of inheritance and polymorphism as separate concepts. But in fact, inheritance is one possible way of implementing polymorphism, which makes the latter the more general concept, and inheritance a special form of the former.

So yes, as you wrote (and as also stated in the article you linked to), every object of every class in Java or C# is polymorphic, since it they all derive from Object. And yes, "as soon as a class inherits from another class, it becomes polymorphic" - that's correct. However, the "opposite" is not mandatory: when objects are polymorphic, that does not necessarily mean there is inheritance involved.

This is probably easier to understand when you have seen examples of polymorphism without inheritance, like Microsoft's component technology COM. For example, using late binding for COM components, it is possible to implement something like a strategy objects without a common base class or an explicitly defined common interface, but with different "strategy" objects. Another example is "static polymorphism" in C++ template meta programming.

You are confused because you think of inheritance and polymorphism as separate concepts. But in fact, inheritance is one possible way of implementing polymorphism, which makes the latter the more general concept, and inheritance a special form of the former.

So yes, as you wrote (and as also stated in the article you linked to), every object of every class in Java or C# is polymorphic, since it they all derive from Object. And yes, "as soon as a class inherits from another class, it becomes polymorphic" - that's correct. However, the "opposite" is not mandatory: when objects are polymorphic, that does not necessarily mean there is inheritance involved.

This is probably easier to understand when you have seen examples of polymorphism without inheritance, like Microsoft's component technology COM. For example, using late binding for COM components, it is possible to implement something like a strategy objects without a common base class or an explicitly defined common interface, but with different "strategy" objects. Another example is "static polymorphism" in C++ template meta programming, or polymorphic functions in Python, like shown here.

added 223 characters in body
Source Link
Doc Brown
  • 220.5k
  • 35
  • 410
  • 625

InheritanceYou are confused because you think of inheritance and polymorphism as separate concepts. But in fact, inheritance is one possible way of implementing polymorphism, which makes the latter the more general concept, and inheritance a special form of the former. 

So yes, as you wrote (and as also stated in the article you linked to), every object of every class in Java or C# is polymorphic, since it they all derive from Object. And yes, "as soon as a class inherits from another class, it becomes polymorphic" - that's correct. However, the "opposite" is not mandatory: when objects are polymorphic, that does not necessarily mean there is inheritance involved.

This is probably easier to understand when you have seen examples of polymorphism without inheritance, like Microsoft's component technology COM. For example, using late binding for COM components, it is possible to implement something like a strategy objects without a common base class or an explicitly defined common interface, but with different "strategy" objects. Another example is "static polymorphism" in C++ template meta programming.

Inheritance is one possible way of implementing polymorphism. So yes, as you wrote (and as also stated in the article you linked to), every object of every class in Java or C# is polymorphic, since it they all derive from Object. And yes, "as soon as a class inherits from another class, it becomes polymorphic" - that's correct. However, the "opposite" is not mandatory: when objects are polymorphic, that does not necessarily mean there is inheritance involved.

This is probably easier to understand when you have seen examples of polymorphism without inheritance, like Microsoft's component technology COM. For example, using late binding for COM components, it is possible to implement something like a strategy objects without a common base class or an explicitly defined common interface, but with different "strategy" objects. Another example is "static polymorphism" in C++ template meta programming.

You are confused because you think of inheritance and polymorphism as separate concepts. But in fact, inheritance is one possible way of implementing polymorphism, which makes the latter the more general concept, and inheritance a special form of the former. 

So yes, as you wrote (and as also stated in the article you linked to), every object of every class in Java or C# is polymorphic, since it they all derive from Object. And yes, "as soon as a class inherits from another class, it becomes polymorphic" - that's correct. However, the "opposite" is not mandatory: when objects are polymorphic, that does not necessarily mean there is inheritance involved.

This is probably easier to understand when you have seen examples of polymorphism without inheritance, like Microsoft's component technology COM. For example, using late binding for COM components, it is possible to implement something like a strategy objects without a common base class or an explicitly defined common interface, but with different "strategy" objects. Another example is "static polymorphism" in C++ template meta programming.

added 223 characters in body
Source Link
Doc Brown
  • 220.5k
  • 35
  • 410
  • 625
Loading
Source Link
Doc Brown
  • 220.5k
  • 35
  • 410
  • 625
Loading