Inheritance allows classes to inherit attributes and methods from a parent class. Polymorphism allows a subclass to override a method from its parent class to perform the same action in different ways. For example, subclasses of Animal like Pig and Dog can override the animalSound() method to output different sounds. This allows a single animalSound() call to behave polymorphically based on the object's type. Inheritance creates an "is-a" relationship where a subclass is a type of its parent class.