Polymorphism works by using the principle of inheritance, which is another fundamental concept in object-oriented systems design. Inheritance allows you to define a general class that contains common attributes and methods, and then create subclasses that inherit from the general class and add specific features. For example, you can define a general class called Animal that has attributes like name, age, and color, and methods like eat, sleep, and make_sound. Then, you can create subclasses like Dog, Cat, and Bird that inherit from Animal and override or extend some of the attributes and methods.
Polymorphism allows you to use the same method name for different subclasses, but execute different code depending on the type of object that calls the method. For example, you can use the same method name make_sound for Dog, Cat, and Bird, but each subclass will have a different implementation of the method that produces a different sound. This way, you can write generic code that can handle different types of objects without knowing their exact details.