I am trying to better my understanding of polymorphism.
Say I have a base class called baseClass with one method called foo() and I have three derived classes called derived1 , derived2 and derived3 which all override the and implement their own versions of the foo() method.
If I have an array of baseClass objects can it contain objects that are derived from that base class like so:
baseClassArray: [ derivedObj1, derivedObj2, derivedObj3];
Also if I pull an object out of this array and called the foo() method would it call the method defined in baseClass or the method defined in the respective derived class?
Or does this depend on the programming language this is implemented in?