1.

Let A and B be objects of class Foo. Which functions are called when print(A + B) is executed?(a) __add__(), __str__()(b) __str__(), __add__()(c) __sum__(), __str__()(d) __str__(), __sum__()

Answer» Right option is (a) __add__(), __str__()

For explanation: The function __add__() is called first since it is within the bracket. The function __str__() is then called on the object that we received after adding A and B.


Discussion

No Comment Found