← Quiz: Python OOP: all 15 questions
Quiz: Python OOP · Question 3 of 15
What does this print? (code)
What does this print?
class A:
def hello(self):
return "A"
class B(A):
def hello(self):
return "B"
print(B().hello())
- A.A
- B.B
- C.AB
- D.Error
Answer & explanation
Correct answer: B
B overrides hello(), so B's version runs. This is polymorphism through overriding.
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 →