Practice mode Python

Inside class Account, an attribute is named __balance. Under which name is it actually stored?

Correct answer D. _Account__balance

Explanation

Names with two leading underscores and at most one trailing underscore are subject to name mangling inside a class body, so __balance becomes _Account__balance. This avoids accidental clashes with names in subclasses. It is not true privacy, since the mangled name can still be accessed.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.