Question d’entretien chez CME Group

What is difference between aggregation and inheritance?

Réponse à la question d'entretien

Utilisateur anonyme

26 juil. 2020

Aggregation: Has-A relationship. We compose a new class(class A) with a component of aggregated class(Class B( inside it . so A -->Has A --> B Inheritance: Is A relationship: We inherit some or all the properties of Parent class (Class A) to the child class (Class B). So, B -->Is a --> A Example: Class A { int meth(){ } } class B extend A{ /*A objA = new A(); objA.meth();*/ int meth(){ syso(B); } }