Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This question is easy... It is <strong>Polymorphism</strong>. </p> <p>The Polymorphic behavior is accomplished because of inheritance. You can treat the instance of Derived as Base because Derived inherits from Base. This is the definition of Polymorphism when applied to types in an OO language...</p> <p><a href="http://en.wikipedia.org/wiki/Polymorphism_(computer_science)" rel="noreferrer">http://en.wikipedia.org/wiki/Polymorphism_(computer_science)</a> </p> <p><strong>[Update, Update]</strong></p> <p>I hope this is definitive enough... these are all different ways of saying the same thing. </p> <p><a href="http://msdn.microsoft.com/en-us/library/ms173152(VS.80).aspx" rel="noreferrer">Polymorphism (C# Programming Guide)</a></p> <blockquote> <p>"Through inheritance, a class can be used as more than one type; it can be used as its own type, any base types, or any interface type if it implements interfaces. This is called polymorphism."</p> </blockquote> <p><strong>[Update]</strong></p> <p>Given the comments I will try to be more specific... I am not saying that because Derived inherits from Base that the line is an example of Polymorphic behavior, I am saying that the assignment of an instance to a variable of a type that it derives from is an example of Polymorphic behavior. To quote the first sentence of the link I attached...</p> <blockquote> <p>"In computer science, polymorphism is a programming language feature that allows values of different data types to be handled using a uniform interface"</p> </blockquote> <p>Meaning that I can treat an instance of Derived as an instance of Base is exhibiting a Polymorphic behavior. This doesn't depend on the existence of virtual methods on the class to be true.</p> <p>and another quote from a <a href="http://en.wikipedia.org/wiki/Polymorphism_in_object-oriented_programming" rel="noreferrer">different source</a>...</p> <blockquote> <p>"In simple terms, polymorphism is the ability of one type, A, to appear as and be used like another type, B. In strongly typed languages, this usually means that type A somehow derives from type B, or type A implements an interface that represents type B."</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload