ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
class A:
def who(self): return "A"
class B(A):
def who(self): return "B" + super().who()
class C(A):
def who(self): return "C" + super().who()
class D(B, C):
def who(self): return "D" + super().who()
print(D().who())- A. DCBA
- B. DBACA
- C. DBCA
- D. DBA
Correct answer: C. DBCA
With multiple inheritance, super() follows the MRO of the actual object, D → B → C → A, not each class's own parent. So B's super() goes to C, not A, and A runs only once: "D" + "B" + "C" + "A".
More Python Programming questions
- What is printed? python try: try: raise ValueError except TypeError: print("T", end=" ") finally: print("F1", end=" ") except ValueError…
- What is printed? python x = 10 def f(a=x): return a x = 20 print(f())
- What is printed? python print(sum(range(1, 10, 2)), list(range(5))[-1:-4:-1])
- What is printed? python print("abc" < "abd" < "ab", "10" < "9", 10 < 9)
- What is printed? python print({x % 3: x for x in range(7)})
- What is printed? python print([(i, j) for i in range(3) for j in range(i)])