1.

Explain operator overloading with the help of an example.

Answer»

The feature where an operator can be used in different forms is known as Operator Overloading. It is one of the methods to implement polymorphism.

'+' operator behaves differently with different data types. With integers it adds the two numbers and with strings it concatenates or joins two strings.

For example: Print 8+9 will give 17 and Print "Python" + "programming" will give the output as Python programming.



Discussion

No Comment Found

Related InterviewSolutions