← Quiz: Polymorphism: all 10 questions
Quiz: Polymorphism · Question 3 of 10
What does this print? (code)
What does this print?
class A:
def show(self): return "A"
class B(A):
def show(self): return "B"
items = [A(), B(), A()]
print("".join(x.show() for x in items))
- A.AAA
- B.ABA
- C.BBB
- D.AB
Answer & explanation
Correct answer: ABA
Each object runs its own show() method.
Can you get the rest right without peeking?
Take the timed Quiz: Polymorphism quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →