Inheritance supports Polymorphism but Polymorphism does not depend on Inheritance.
You gave an example how to achief Polymorphism via Inheritance.
But you could look at it differently:
There is an interface for the concept of moving:
interface Movable{
void move();
}
Animals may implement this interface:
class Dog implements Movable {
@Override
public void move(){
// move the animal
}
}
but some fungis can also move:
class SlimeMold implements Movable {
@Override
public void move(){
// move the animal
}
}
There is hardly to find an "is a" relationship between those two which could be expressed by inheritance, but when both implement the same interface we can still apply Polymorphism on them:
Collection movables = new HashSet<>();
movables.add(new Dog());
movables.add(new SlimeMold());
for(Movable movable : movables)
movable.move();