11. What does built-in function type do in context of classes?
a) Determines the object name of any value
b) Determines the class name of any value
c) Determines class description of any value
d) Determines the file name of any value
12. Which of the following is not a type of inheritance?
a) Double-level
b) Multi-level
c) Single-level
d) Multiple
13. What does built-in function help do in context of classes?
a) Determines the object name of any value
b) Determines the class identifiers of any value
c) Determines class description of any built-in type
d) Determines class description of any user-defined built-in type
14. What will be the output of the following Python code?
class A:
def one(self):
return self.two()
def two(self):
return ‘A’
class B(A):
def two(self):
return ‘B’
obj1=A()
obj2=B()
print(obj1.two(),obj2.two())
a) A A
b) A B
c) B B
d) An exception is thrown
15. What type of inheritance is illustrated in the following Python code?
class A():
pass
class B():
pass
class C(A,B):
pass
a) Multi-level inheritance
b) Multiple inheritance
c) Hierarchical inheritance
d) Single-level inheritance
16. What type of inheritance is illustrated in the following Python code?
class A():
pass
class B(A):
pass
class C(B):
pass
a) Multi-level inheritance
b) Multiple inheritance
c) Hierarchical inheritance
d) Single-level inheritance
17. What does single-level inheritance mean?
a) A subclass derives from a class which in turn derives from another class
b) A single superclass inherits from multiple subclasses
c) A single subclass derives from a single superclass
d) Multiple base classes inherit a single derived class
18. What will be the output of the following Python code?
class A:
def __init__(self):
self.__i = 1
self.j = 5
def display(self):
print(self.__i, self.j)
class B(A):
def __init__(self):
super().__init__()
self.__i = 2
self.j = 7
c = B()
c.display()
a) 2 7
b) 1 5
c) 1 7
d) 2 5
19. Which of the following statements isn’t true?
a) A non-private method in a superclass can be overridden
b) A derived class is a subset of superclass
c) The value of a private variable in the superclass can be changed in the subclass
d) When invoking the constructor from a subclass, the constructor of superclass is automatically invoked
20. What will be the output of the following Python code?
class A:
def __init__(self,x):
self.x = x
def count(self,x):
self.x = self.x+1
class B(A):
def __init__(self, y=0):
A.__init__(self, 3)
self.y = y
def count(self):
self.y += 1
def main():
obj = B()
obj.count()
print(obj.x, obj.y)
main()
a) 3 0
b) 3 1
c) 0 1
d) An exception in thrown
Page 1 2 3
Python Interview Questions (MCQs)
We have divided these Python Questions and Answers into various parts based on the topics. Open the Topic of your choice and Practice these MCQs.