Certified Associate in Python Programming (PCAP) — Question 74
If any of a class's components has a name that starts with two underscores (___), then:
Answer options
- 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
Correct answer: A
Explanation
When a class's component name starts with two underscores, Python applies name mangling to prevent naming conflicts in subclasses. Options B, C, and D are incorrect because they do not pertain to the naming conventions associated with underscores in Python; the name mangling is specifically related to encapsulation and not the type of variable or method.