Python Programming (2180711) MCQs

MCQs of Classes and Object-Oriented Programming

Showing 21 to 30 out of 45 Questions
21.
When defining a subclass in Python that is meant to serve as a subtype, the subtype Python keyword is used.
(a) TRUE
(b) FALSE
Answer:

Option (b)

22.
Suppose B is a subclass of A, to invoke the __init__ method in A from B, what is the line of code you should write?
(a) A.__init__(self)
(b) B.__init__(self)
(c) A.__init__(B)
(d) B.__init__(A)
Answer:

Option (a)

23.
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
Answer:

Option (b)

24.
Which of the following is not a type of inheritance?
(a) Double-level
(b) Multi-level
(c) Single-level
(d) Multiple
Answer:

Option (a)

25.
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
Answer:

Option (c)

26.
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
Answer:

Option (a)

27.
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
Answer:

Option (c)

28.
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
Answer:

Option (c)

29.
Which of the following statements is true?
(a) The __new__() method automatically invokes the __init__ method
(b) The __init__ method is defined in the object class
(c) The __eq(other) method is defined in the object class
(d) The __repr__() method is defined in the object class
Answer:

Option (c)

30.
Method issubclass() checks if a class is a subclass of another class.
(a) TRUE
(b) FALSE
Answer:

Option (a)

Showing 21 to 30 out of 45 Questions