Pregunta de entrevista de CME Group

What is difference between aggregation and inheritance?

Respuesta de la entrevista

Anónimo

26 jul 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); } }