Python supports this. Please use below example
test.py - Example of runtime polymorphism
class Shark():
def swim(self):
print("The shark is swimming.")
def swim_backwards(self):
print("The shark cannot swim backwards, but can sink backwards.")
def skeleton(self):
print("The shark's skeleton is made of cartilage.")
class Clownfish():
def swim(self):
print("The clownfish is swimming.")
def swim_backwards(self):
print("The clownfish can swim backwards.")
def skeleton(self):
print("The clownfish's skeleton is made of bone.")
def in_the_pacific(fish):
fish.swim()
sammy = Shark()
casey = Clownfish()
in_the_pacific(sammy)
in_the_pacific(casey)
output of test.py
root@e9076f0e6e52:/ws1/rs_121_48_triton/usr.src/netscaler# python test.py
The shark is swimming.
The clownfish is swimming.
Useful link: https://www.digitalocean.com/community/tutorials/how-to-apply-polymorphism-to-classes-in-python-3
https://www.geeksforgeeks.org/dynamic-method-dispatch-runtime-polymorphism-java/