0

I have done some research and googled a lot. I have some confusion to confirm either my scenarios are correct or not.

Here is first question:

With reference to Figure down, what do you think is the most likely implementation of the relationship between Car and Passengers? Choose only one option

enter image description here

          A.          Inheritance
          B.          Association
          *C.        Aggregation
          D.          Composition

So, the answer is Aggregation as I understand the scenario and googled but I need confirmation from other developers.

Here is second question:

With reference to Figure down, what do you think is the most likely implementation of the relationship between Apple and Fruit?

enter image description here

          A.          Inheritance
          B.          Association
          C.          Aggregation
          *D.         Composition

So, the answer is Composition I understand the scenario and googled but I need confirmation from other developers.

All these above questions are from well knows internet sites, now I am confuse what is the logic behind it.

Regards

Micho
  • 3,929
  • 13
  • 37
  • 40
  • 1
    No. Apple inherits from Fruit because Apple IS A Fruit. – qwerty_so Oct 06 '17 at 08:15
  • 2
    Possible duplicate of [Prefer composition over inheritance?](https://stackoverflow.com/questions/49002/prefer-composition-over-inheritance) – qwerty_so Oct 06 '17 at 08:17
  • I am not sure that we can answer to the question, of course the remark of @Kilian about inheritance is meaning full, but the choice between association or composition depends on the context ... And you should avoid aggregation which is not well defined in UML. You knonw, on stackoverflow there are a lot's of questions about this topic ... – granier Oct 06 '17 at 12:03
  • @granier I did not moan the composition, although you are right. The problem is that teachers still believe that there is some semantics because in the past UML version were wishy washy here. – qwerty_so Oct 06 '17 at 14:45
  • You're right, some teachers are not up-to-date :) all students know that :) – granier Oct 06 '17 at 16:11
  • 1
    Possible duplicate of [What is the difference between association, aggregation and composition?](https://stackoverflow.com/questions/885937/what-is-the-difference-between-association-aggregation-and-composition) – Geert Bellekens Oct 07 '17 at 12:47

0 Answers0