Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

has-a. equals (maintains No Relationship)

 
Louie van Bommel
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found this on a mock exam.



Which statements are true about the relationship between ClassA and ClassB?

Answer:
1. Class1 maintains no relationship with Class2
2. The relationship can be described with a has-A.


(I chose #2, and not #1)

It seems to me that Class2 has-a Class1
and Class1 and Class2 enjoy a "has-a" relationship.

Is this kind of wording "maintains no relationship with" likely to appear on the exam? If so, why do you suppose I didn't pick answer #1?
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I doubt you'll see such a question on the exam. And, if you do, I can almost guarantee that the wording will be much less ambiguous than that.

From that question, I'd say you selected the correct answer.
 
Edwin Keeton
Ranch Hand
Posts: 214
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the sample, Class2 does maintain a relationship (the has-A kind) with Class1. But the relationship between Class2 and Class1 is uni-directional since Class1 does not maintain a relationship with Class2.

(A relationship between classes is "maintained" by a class holding a reference to another class. Class2 holds a reference to Class1 whereas Class1 does not hold a reference to Class2).

The question asks about the relationship between Class1 and Class2, not about the relationship between Class2 and Class1.

Based on this interpretation of the question, answer 1 is correct.

On the real exam you won't have questions requiring this much subtlety of interpretation.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic