🎙 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 9 of 15

What does this print? (code)

What does this print?

class P:
    def __init__(self):
        self.__secret = 1
print(hasattr(P(), "__secret"))
  1. A.True
  2. B.False
  3. C.1
  4. D.An error
Answer & explanation

Correct answer: False

Name mangling renames it to _P__secret.

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 →