Loading

Quipoin Menu

Learn • Practice • Grow

Direction: Choose the correct option

Q1.

What is inheritance in Python?
A. A method overloading
B. A type of encapsulation
C. A mechanism to create a new class from an existing class
D. A way to create multiple objects
Direction: Choose the correct option

Q2.

How do you define class B that inherits from class A?
A. class B(A):
B. class B extends A:
C. class B inherits A:
D. class B = A:
Direction: Choose the correct option

Q3.

What is method overriding?
A. Defining a new method
B. Redefining a method in a subclass that already exists in the superclass
C. Overloading a method
D. Calling a method from the superclass
Direction: Choose the correct option

Q4.

How do you call the parent class's method from the child class?
A. super().method()
B. parent.method()
C. super.method()
D. self.parent.method()
Direction: Choose the correct option

Q5.

What is multiple inheritance?
A. A class inheriting from more than one base class
B. A class inheriting from itself
C. A class inheriting from one base class
D. A class with multiple methods
Direction: Choose the correct option

Q6.

What is the output of `class A: pass; class B(A): pass; print(issubclass(B, A))`?
A. TRUE
B. FALSE
C. Error
Direction: Choose the correct option

Q7.

What is the method resolution order (MRO)?
A. The order in which Python searches for methods in class hierarchy
B. The order of methods
C. The order of attributes
D. The order of classes
Direction: Choose the correct option

Q8.

What does `super().__init__()` do in the child's `__init__`?
A. Initializes the child
B. Calls the parent class's initializer
C. Raises an error
D. Creates a super object
Direction: Choose the correct option

Q9.

What is the output of `class A: def f(self): return 'A'; class B(A): def f(self): return 'B'; print(B().f())`?
A. Error
B. 'B'
C. 'AB'
D. 'A'
Direction: Choose the correct option

Q10.

What does `isinstance(obj, (A, B))` check?
A. If obj is an instance of B
B. If obj is an instance of both A and B
C. If obj is an instance of any of the classes in the tuple
D. If obj is an instance of A