6.
Which of the following shows multiple inheritances?
a) A->B->C
b) A->B; A->C
c) A,B->C
d) B->A
Answer: c
Explanation:
In multiple inheritance, a single class is inherited from two classes. So in A,B->C, Class C is inherited from A and B, whereas in A->B->C, C from B and B from A called simple inheritance, in A->B; A->C, B and C are inherited from A which is called hierarchical inheritance.
7.
How access specifiers in Class helps in Abstraction?
a) They does not helps in any way
b) They allows us to show only required things to outer world
c) They help in keeping things together
d) Abstraction concept is not used in classes
Answer: b
Explanation:
Abstraction is the concept of hiding things from the outer world and showing only the required things to the world, which is where access specifiers private, protected and public helps in keeping our knowledge hidden from the world.
8.
C++ is ______________
a) procedural programming language
b) object oriented programming language
c) functional programming language
d) both procedural and object oriented programming language
Answer: d
Explanation:
C++ supports both procedural(step by step instruction) and object oriented programming(using concept of classes and objects).
9.
What does modularity mean?
a) Hiding part of program
b) Subdividing program into small independent parts
c) Overriding parts of program
d) Wrapping things into single unit
Answer: b
Explanation:
Modularity means dividing a program into independent sub programs so that it can be invoked from other parts of the same program or any other program.
10.
Which of the following feature of OOPs is not used in the following C++ code?
class A
{
int i;
public:
void print(){cout<<“hello”<<i;}
}
class B: public A
{
int j;
public:
void assign(int a){j = a;}
}
a) Abstraction
b) Encapsulation
c) Inheritance
d) Polymorphism
Answer: d
Explanation:
As i and j members are private i.e. they are hidden from outer world therefore we have used the concept of abstraction. Next data members and there related functions are put together into single class therefore encapsulation is used. Also as class B is derived from A therefore Inheritance concept is used. But as no function is overloaded in any of the classes therefore, the concept of polymorphism is missing here.