Question: Few questions on object-oriented programming in python 3 1. Assuming that the __add__ operator is implemented for two objects, x and y , then x+y

Few questions on object-oriented programming in python 3

1. Assuming that the __add__ operator is implemented for two objects, x and y, then x+y is equivalent to:

A. add(x,y)

B. y.__add__(x)

C. x.__add__(y)

D. __add__(x,y)

2. A class can define the behavior for the < operator.

A. True

B. False

3. The method name for non-integer division is:

A. /

B. __div__

C. //

D. __truediv__

4. By default calling the str function on a custom object will:

A. print the memory address of that object

B. print the name of the object

C. print a description of that object

D. print the name of the class

5. Typically, a definition of the __add__ method should:

A. Change the left operand

B. Return a new instance of the left operand type

C. Change the right operand

D. Return a new instance of the right operand type

6. By default, if you use the + operator on two user-defined objects:

A. The two objects will be added together

B. the two objects will be combined

C. an error will occur.

D. a new object will be created

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!