When is it wise to use polymorphism over Inheritance?
So, let’s say we have
public class Lion extends Animals {} ;
OR
Animals ani = new Lion();
I would mostly prefer inheritance, since we have solid class to use.
Does it come down to which one runs faster?
There is no Or to that.
defines a class Lion, that descends from a class animal
defines an variable ani of type Animals and assigns a new instance of Lion to it.
If Lion didn’t descend from Animals, then you’d get a error, is about all we can say.