🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Encapsulation and Abstraction: all 10 questions

Quiz: Encapsulation and Abstraction · Question 7 of 10

In Python, what does self.balance (double underscore) do?

In Python, what does self.__balance (double underscore) do?

  1. A.Makes the attribute truly private and impossible to reach
  2. B.Triggers name mangling, so outside code writing acc.__balance creates a different attribute
  3. C.Makes the attribute read-only
  4. D.Deletes the attribute after use
Answer & explanation

Correct answer: Triggers name mangling, so outside code writing acc.__balance creates a different attribute

Python has conventions and name mangling, not true private variables.

Can you get the rest right without peeking?

Take the timed Quiz: Encapsulation and Abstraction quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →