Certified Associate in Python Programming (PCAP-31-03) — Question 54
What is true about Object-Oriented Programming in Python? (Choose two.)
Answer options
- A. an object is a recipe for a class
- B. the arrows on a class diagram are always directed from a superclass towards its subclass
- C. encapsulation allows you to protect some data from uncontrolled access
- D. inheritance is the relation between a superclass and a subclass
Correct answer: C, D
Explanation
Option C is correct because encapsulation is a principle that restricts access to certain components of an object, enhancing security. Option D is also correct as it defines inheritance, which establishes a hierarchy between classes. Options A and B are incorrect; A mischaracterizes the relationship between objects and classes, and B is inaccurate regarding the directionality of arrows in class diagrams.