Question: 11 -
Which among the following is correct for multiple inheritance?
-
class student{int marks;}; class stream:public student{ };
-
class student{int marks;}; class stream{ }; class topper: public student{ };
-
class student{ }; class stream{ }; class topper{ };
-
class student{public: int marks;}s; class stream{int total;}; class topper:public student, public stream{ };
Answer:
class student{public: int marks;}s; class stream{int total;}; class topper:public student, public stream{ };
Solution not available.
Question: 12 -
Which among the following best defines single level inheritance?
-
A class which gets inherited by 2 classes
-
A class inheriting a nested class
-
A class inheriting a base class
-
A class inheriting a derived class
Answer:
A class inheriting a base class
Solution not available.
Question: 13 -
Which is the correct syntax of inheritance?
-
class derived_classname : base_classname{ /*define class body*/ };
-
class base_classname :access derived_classname{ /*define class body*/ };
-
class derived_classname : access base_classname{ /*define class body*/ };
-
class base_classname : derived_classname{ /*define class body*/ };
Answer:
class derived_classname : access base_classname{ /*define class body*/ };
Solution:
Firstly, keyword class should come, followed by the derived class name. Colon is must followed by access in which base class has to be derived, followed by the base class name. And finally the body of class. Semicolon after the body is also must.
Firstly, keyword class should come, followed by the derived class name. Colon is must followed by access in which base class has to be derived, followed by the base class name. And finally the body of class. Semicolon after the body is also must.
Question: 14 -
How many basic types of inheritance are provided as OOP feature?
-
2
-
4
-
3
-
1
Answer:
4
Solution:
There are basically 4 types of inheritance provided in OOP, namely, single level, multilevel, multiple and hierarchical inheritance. We can add one more type as Hybrid inheritance but that is actually the combination any types of inheritance from the 4 basic ones.
There are basically 4 types of inheritance provided in OOP, namely, single level, multilevel, multiple and hierarchical inheritance. We can add one more type as Hybrid inheritance but that is actually the combination any types of inheritance from the 4 basic ones.
Question: 15 -
Which among the following is correct for a hierarchical inheritance?
-
One base class can be derived into only 2 classes
-
One base class can be derived into other two derived classes or more
-
Two base classes can be used to be derived into one single class
-
Two or more classes can be derived into one class
Answer:
One base class can be derived into other two derived classes or more
Solution:
One base class can be derived into the other two derived classes or more. If only one class gets derived by only 2 other classes, it is also hierarchical inheritance, but it is not a mandatory condition, because any number of derived classes can be there.
One base class can be derived into the other two derived classes or more. If only one class gets derived by only 2 other classes, it is also hierarchical inheritance, but it is not a mandatory condition, because any number of derived classes can be there.