Python Multiple Choice Questions And Answers
Are you preparing for the next job interviews? If yes, trust me this post will help you also we'll suggest you check out a big collection for Programming Full Forms that may help you in your interview:
List of Programming Full Forms
Refer documentation.
- __add__()
- __plus__()
- __sum__()
- none of the mentioned
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.
- __add__(), __str__()
- __str__(), __add__()
- __sum__(), __str__()
- __str__(), __sum__()
class A:
def __init__(self): self.__x = 1
class B(A):
def display(self):
print(self.__x)
def main():
obj = B()
obj.display()
main()
Private class members in the superclass can’t be accessed in the subclass.
- Error, invalid syntax for object declaration
- Error, private class member can’t be accessed in a subclass
t[5]
The expression shown above results in a name error. This is because the name ‘t’ is not defined.
- IndexError
- NameError
- TypeError
- syntaticalError