a. 4
b. 3
c. 2
d. 1.
The correct option is (a)
Explanation:
There are basically 4 types of inheritance provided in OOP, namely, single level, multilevel, multiple and hierarchical inheritance.
a. A class inheriting a base class
b. A class inheriting a nested class
c. A class inheriting a derived class
d. A class which gets inherited by 2 classes
Show Answer
The correct option is (a)
Explanation:
A class inheriting a base class defines single level inheritance. Inheriting an already derived class makes it multilevel inheritance. And if base class is inherited by 2 other classes, it is multiple inheritance.
3. Which programming language does not support multiple inheritance?
a. C and C++
b. Java and SmallTalk
c. C++ and Java
d. Java
Show Answer
The correct option is (d)
Explanation:
Java doesn’t support multiple inheritance. But that feature can be implemented by using the interfaces concept
4. Which type of inheritance leads to diamond problem?
a. Multi-level
b. Multiple
c. Hierarchical
d. Multiple
Show Answer
The correct option is (d)
Explanation:
When 2 or more classes inherit the same class using multiple inheritance and then one more class inherits those two base classes, we get a diamond like structure. Here, ambiguity arises when same function gets derived into 2 base classes and finally to 3rd level class because same name functions are being inherited.
5. Which access type data gets derived as private member in derived class?
a. Public
b. Protected
c. Protected and Private
d. Private
Show Answer
The correct option is (d)
Explanation:
It’s rule, that when a derived class inherits the base class with the private access mode, all the data members of base class gets derived as private members of the derived class.
6. Members or class which are not intended to be inherited are declared as ________________
a. Protected members
b. Private members
c. Private or Protected members
d. Public members
Show Answer
The correct option is (b)
Explanation:
Private access modifier is the most secure access mode. It doesn’t allow members or class to be inherited. Even Private inheritance can only inherit protected and public members.
7. base class and derived class relationship comes under ?
a. Polymorphism
b. encapsulation
c. Inheritance
d. None
Show Answer
The correct option is (c)
Explanation:
Base class and derived class come under inheritance, one of the C++ oops principle.
8. C++ Inheritance relationship known ??
a. Has-A
b. Is-A
c. Association
d. None
Show Answer
The correct option is (b)
Explanation:
IS A Relationship is related to inheritance in C++.
9. Inheritance allow in C++ Program?
a. Creating a hierarchy of classes
b. Extendibility
c. Class Re-usability
d. All
Show Answer
The correct option is (d)
Explanation:
Advantage of inheritance are like re-usability- You can re-use existing class in a new class that avoid re-writing same code.
10. If the derived class is struct, then default visibility mode is _______ ?
a. protected
b. public
c. private
d. struct can’t inherit class
Show Answer
The correct option is (b)
Explanation:
No Explanation