मराठी

Explain polymorphism with an example.

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
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 2: Concept of Object Oriented Programming - EXCERCISE [पृष्ठ ३७]

APPEARS IN

सीबीएसई Computer Science with Python [English] Class 12
पाठ 2 Concept of Object Oriented Programming
EXCERCISE | Q 8. | पृष्ठ ३७
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×