I was studying about polymorphism. I couldn’t determine the analogy in Java about these two features.
Let’s say Animal class is a concrete superclass with Cat and Dog as its subclasses. I know that this is a case of inheritance. But isn’t Cat and Dog classes, polymorphs of Animal class?
I am well aware of interfaces in Java. I couldn’t understand why interfaces are used instead of concrete classes to explain polymorphism. It could be that the whole purpose of creating interface is to create polymorphs but I want to know why interfaces and not concrete classes?
Inheritance
Polymorphism
Why Interface ?
You know what needs to be done, but you want implementers to decide how to do it, You will let implementer implement the stuffs forcefully