1. | What is inheritance? |
|
2. | What is simple inheritance? |
|
3. | What is level inheritance? |
|
4. | What is multiple inheritance? |
|
5. | What is the is a test? |
|
6. | When would you use multiple inheritance? |
|
7. | When would you use level inheritance? |
|
8. | What is the maximum number of levels in level inheritance? |
|
9. | What members of a class can another class inherit? |
|
10. | What is the difference between base class/derived class and super class/subclass? |
|
Answers
1. | Inheritance is a programming technique that enables a class to inherit some or all attributes and behaviors of another class. |
2. | Simple inheritance is a type of inheritance in which a class inherits from just one class. |
3. | Level inheritance is a type of inheritance in which two or more levels of inheritance exist. Each level consists of a parent-child relationship whereby the child of the middle level is also the parent of the lower level. The last child in level inheritance inherits directly and indirectly from other levels. |
4. | Multiple inheritance is a type of inheritance in which a child inherits from multiple parents, but no relationship exists among those parents. |
5. | The is a test is given to determine if a child is a parent. For example, is a graduate student a student? If so, the child (graduate student) can inherit from the parent (student). If not, the child cannot inherit from the parent. |
6. | Multiple inheritance should be used whenever a child needs to inherit attributes and behaviors from parents that are not related to each other. |
7. | Level inheritance should be used whenever a child needs to inherit attributes and behaviors from parents that are related to each other. |
8. | There is no maximum number of levels in level inheritance. However, you should use no more than three levels; otherwise , you run the risk that the levels will become unmanageable. |
9. | A child can inherit public and protected members of a parent class. |
10. | Base class is the term used in C++ to refer to a parent class. Derived class is the C++ term for a child class. A super class is Java s parent class, and Java s child class is called a subclass. |