Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam PCAP All Questions

View all questions & answers for the PCAP exam

Exam PCAP topic 1 question 66 discussion

Actual exam question from Python Institute's PCAP
Question #: 66
Topic #: 1
[All PCAP Questions]

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

  • A. the class component's name will be mangled
  • B. the class component has to be an instance variable
  • C. the class component has to be a class variable
  • D. the class component has to be a method
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️
Reference:
https://hackernoon.com/understanding-the-underscore-of-python-309d1a029edc

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Adeshina
1 year, 11 months ago
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.
upvoted 4 times
...
Janpcap123
2 years, 4 months ago
Absolutely A is the answer.
upvoted 1 times
...
macxsz
2 years, 7 months ago
Selected Answer: A
A. the class component's name will be mangled
upvoted 1 times
...
AlMargoi
2 years, 8 months ago
Selected Answer: A
I think answer is A
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...