LearnFrenzy
Sign in Take a free test

Inheritance and Polymorphism · Inheritance and Polymorphism MCQ · Question 11

Overloading + Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 11 Back to Exercise

Which method makes a + b work for objects of your class?

  • A __add__ Correct
  • B __plus__
  • C __sum__
  • D __concat__
Correct Answer: Option A

a + b calls a.__add__(b); if that returns NotImplemented, Python tries b.__radd__(a).

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links