🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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())
  1. A.A A
  2. B.A C
  3. C.C C
  4. 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 →