Advertisements
Advertisements
प्रश्न
Explain polymorphism with an example.
स्पष्ट करा
Advertisements
उत्तर
Polymorphism means “many forms”. It is the ability of the same operator or function name to behave differently for different data or arguments.
Example — operator overloading: The + operator adds numbers but joins strings.
print(8 + 9) # Addition: 17
print("Python " + "Programming") # Concatenation: Python Programming
Thus, the same + operator performs different operations according to the type of operands.
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
