🎙 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 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)
  1. A.woof woof
  2. B.bark bark
  3. C.woof bark
  4. 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 →