Difficulty: Easy
Correct Answer: has a relationship
Explanation:
Introduction / Context:
Object-oriented design uses relationship vocabulary to describe how types relate. “Is-a” denotes inheritance (a specialized kind of the base), while “has-a” denotes composition/aggregation (an object contains or owns another object). Correctly identifying the relationship guides design choices like lifetime management and interface exposure.
Given Data / Assumptions:
Concept / Approach:
The presence of an Engine data member inside Bike indicates composition: a Bike has an Engine. This is typically a strong “has-a” relationship, often implying ownership and synchronized lifetimes (the Engine subobject is constructed and destroyed with the Bike). An “is-a” (inheritance) relationship would have used the syntax class Bike : public Engine { ... };. Vague phrases like “kind of relationship” do not correspond to standard OO terminology and are not specific enough to be correct here.
Step-by-Step Solution:
Verification / Alternative check:
Consider construction order: when a Bike is created, its Engine member is constructed first. On destruction, Engine is destroyed last among members. This lifecycle coupling is characteristic of composition and confirms the “has-a” judgment.
Why Other Options Are Wrong:
kind of relationship — not a standard term; too vague.
Inheritance — would require class Bike : public Engine, which is absent.
Both A and B — includes a non-standard term; only “has a relationship” fits.
Common Pitfalls:
Final Answer:
has a relationship
Discussion & Comments