What is the difference between Inheritance and Aggrigation?

Showing Answers 1 - 10 of 10 Answers

Nagapratap

  • Jun 7th, 2006
 

Inheritance is a class extending another class. Abstraction is an inteface implementing another interface, so that a class implementing the interface A whch implements interface B should provide the implementation for all the methods in interface A and interface B

  Was this answer useful?  Yes

Inheritence is inclusion of behaviour and/or state in the derived class.

Aggregation is an association in which one class belongs to a collection. This is part of whole relationship where a part can exist without a whole. This is also called weaker relationship.
Aggregation is usually compared to composition which is a stronger relationship. This is part of whole relationship where a part cannot exist without whole.

  Was this answer useful?  Yes

If we have to explain it with example, then Inheritance (IS A or TYPE OF) & Aggregation (HAS A) can be understood as:

a CAR IS A (an) Automobile.   (Inheritance: Car inherits its properties from Automobile)
While
a CAR HAS A (an) engine. (Aggregation: Car Class has an Object of engine class)

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions