PCAP Exam QuestionsBrowse all questions from this exam

PCAP Exam - Question 66


If any of a class's components has a name that starts with two underscores (___), then:

Show Answer
Correct Answer: A

If any of a class's components has a name that starts with two underscores (___), then the class component's name will be mangled. This means that the interpreter modifies the variable name to include the class name, making it harder to create subclasses that accidentally override the private attributes and methods. This name mangling is done to avoid naming conflicts in subclasses.

Discussion

4 comments
Sign in to comment
AdeshinaOption: A
Dec 12, 2022

A the double underscore (__) prefix is used to denote so-called "private" class members, i.e. class attributes or methods that are intended to be used only within the class or its subclasses, and should not be accessed directly from outside the class. When a class member is given a double underscore prefix, the interpreter automatically mangles the name of the member by adding a prefix and a suffix to it. This is done to prevent name clashes between class members with the same name but defined in different classes.

AlMargoiOption: A
Mar 28, 2022

I think answer is A

macxszOption: A
May 3, 2022

A. the class component's name will be mangled

Janpcap123Option: A
Jul 26, 2022

Absolutely A is the answer.