🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Python OOP: all 15 questions

Quiz: Python OOP · Question 8 of 15

What does this print? (code)

What does this print?

class A:
    def hi(self):
        return "A"
class B(A):
    def hi(self):
        return "B" + super().hi()
print(B().hi())
  1. A.B
  2. B.BA
  3. C.AB
  4. D.An error
Answer & explanation

Correct answer: BA

B overrides hi and calls the parent's version.

Can you get the rest right without peeking?

Take the timed Quiz: Python OOP quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →