← Quiz: Inheritance: all 10 questions
Quiz: Inheritance · Question 2 of 10
What does this print? (code)
What does this print?
class A:
def hi(self): return "A"
class B(A):
pass
class C(B):
def hi(self): return "C"
print(B().hi(), C().hi())
- A.A A
- B.A C
- C.C C
- D.B C
Answer & explanation
Correct answer: A C
B inherits hi() from A; C overrides it.
Can you get the rest right without peeking?
Take the timed Quiz: Inheritance quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →