It s obvious. It depends on what A and B are. If they refer to an apple and fruit, then use inheritance. If they refer to a person and an age, use aggregation. Inheritance is used for an is a relationship.
Aggregation is used for a has a relationship.
I ll let you draw your own conclusions about people who answer number 1 or number 2. People who give answer number 3 show they can apply the correct basic principles, even if they do not know what those principles are. The correct textbook answer is number 4. Unfortunately, even among those with recent degrees in computer science, very few are able to provide this answer. Object-oriented design is much more than just creating a class by inheriting from another class and adding members.