Objects Questions and Answers
Practice ModeShowing 10 of 25 questions
Q21
What is composition in object-oriented programming?
Answer: Option B
Explanation: Composition is a design principle where a class contains objects of other classes as members.
Q22
What is the purpose of the @property decorator?
Answer: Option B
Explanation: The @property decorator allows a method to be accessed like an attribute while providing getter functionality.
Q23
What is abstraction in Python?
Answer: Option B
Explanation: Abstraction hides complex implementation details and shows only essential features to the user.
Q24
What are abstract base classes (ABC) in Python?
Answer: Option B
Explanation: Abstract base classes cannot be instantiated and require subclasses to implement abstract methods.
Q25
What is the difference between "is" and "==" in Python?
Answer: Option B
Explanation: "is" checks for identity (same object in memory), while "==" checks for equality (same value).