C++ Programming - OOPS Concepts - Discussion

Discussion Forum : OOPS Concepts - General Questions (Q.No. 13)
13.
Which of the following concepts provides facility of using object of one class inside another class?
Encapsulation
Abstraction
Composition
Inheritance
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
48 comments Page 1 of 5.

Hamdan Ali said:   4 years ago
It's a part of Association, where two classes communicate each other but don't have a relationship and inside Association the form of Aggregation where two classes objects can communicate each other but one class denotes as owner and one class denotes its part for example Department has lecturers if department object destroys lecturers will exist another example Address can relate to one and more entity if people those are living on that address leave the address so the address will exist and inside aggregation, the form is composition, whether one entity lifecycle depends on another entity, means like if House and Room relationship if the house will destroy room will also destroy this called composition.
(7)

Sparsh Gupta said:   4 years ago
Inheritance will acquire one class properties, but here the question is not about the class, it's about an object inside a class, so the answer is composition.
(5)

Bhuneshwar Mahto said:   4 years ago
I don't know about composition please tell me, anyone, in detail about composition.
(4)

Sunil said:   6 years ago
Composition is a HAS-A relationship. One class can hold the object of another class and also manages its life-cycle. So we can class A has a B class object.

Inheritance is IS-A relationship. Derived class is derived from the base class. So we can say that derived class is a base class (since it holds all the properties which is in base class).
(2)

Hardeep said:   10 years ago
Can anyone explain me relationship between inheritance and composition?

Shivani said:   10 years ago
Is composition similar to inheritance?

Ashwini said:   9 years ago
Why you answering as composition instead of inheritance?

Payal said:   9 years ago
What is Composition?

Sarang patrange said:   9 years ago
When object is made from other small object it is called composition?

Sarang patarnge said:   9 years ago
Inheritance is relation in which, one class shares behaviors of one or more classes. Also in inheritance, subclass represents general behavior of its super class.

In composition allows physical grouping of logically related structures while inheritance allows common groups to be easily reused among different abstractions.

Eg. Room has wall, System unit has motherboard.


Post your comments here:

Your comments will be displayed after verification.