Multiple choice technology programming languages

Which two statements are true about has-a and is-a relationships? (Choose two.)

  1. Inheritance represents an is-a relationship

  2. . Inheritance represents a has-a relationship

  3. Interfaces must be used when creating a has-a relationship

  4. Instance variables can be used when creating a has-a relationship

Reveal answer Fill a bubble to check yourself
A,D Correct answer
Explanation

Inheritance models an is‑a relationship (a subclass is‑a type of its superclass). A has‑a relationship is expressed by including instance variables that reference other objects. Therefore the true statements are the inheritance one and the instance‑variable one; the others mischaracterize the relationships.