← Quiz: Python OOP: all 15 questions
Quiz: Python OOP · Question 6 of 15
What does this print? (code)
What does this print?
class Dog:
sound = "woof"
a, b = Dog(), Dog()
Dog.sound = "bark"
print(a.sound, b.sound)
- A.woof woof
- B.bark bark
- C.woof bark
- D.An error
Answer & explanation
Correct answer: bark bark
Class attributes are shared by all objects.
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 →