c++
1. (TCO 3) Which of the following about composition is true? (Points : 2)
Composition promotes code reuse.
Class composition means a class contains objects from another class.
Inheritance and composition can be used together.
All of the above
A child class can have more functionality than parent class. |
Manager |
Airplanes |
person/employee |
Systems can be tested independently. |
inherits only from its parent class |
Private |
reusability in object oriented programming |
family |
Expert Answer
All of the above
Because both the inheritance and also composition can promote code reuse and also both these can be used together.
2.C
Common functionality needs to be designed in the parent class this statement represents false because it is not mandatory to write the common functionality in parent class we can also write in the child class and that child class can be act as parent class.
3.A
manager is the parent class because we can inherit all the remaining people from him he will act as parent classs.
4. A
Airplanes is not a good example of a hierarchy that could be modeled by inheritance.
5.D
“is-a” relationship satisfies all the conditions
6.D
Systems can be tested, built and can be maintained independently.
7.C
In object-oriented programming, inheritance is transitive; that means a child class inherits all the methods and fields of all its ancestors.
8.C
Public inheritance mode is the most general one because the child class can be inherit easily through out the application.
9.D
Composition is reusability in object oriented programming and also objects to communicate and identification of classes.
10.B
The whole list of parent classes from which a child class is derived constitutes the ancestors of the child class.