C++ Programming Quizs Question MCQ – OOPs

Q 1. Which of the following shows multiple inheritances?
A. A->B->C
B. A->B; A->C
C. A,B->C
D. B->A

Show Answer Answer:-C. A,B->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.

Q 2. 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

Show Answer Answer:-B. They allows us to show only required things to outer world
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.

Q 3. C++ is ______________
A. procedural programming language
B. object oriented programming language
C. functional programming language
D. both procedural and object oriented programming language

Show Answer Answer:-D. both procedural and object oriented programming language
Explanation C++ supports both procedural(step by step instruction) and object oriented programming(using concept of classes and objects).

Q 4. 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

Show Answer Answer:-B. Subdividing program into small independent parts
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.

Q 5. 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

Show Answer Answer:-D. Polymorphism
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.

Q 6. Which concept allows you to reuse the written code?
A. Encapsulation
B. Abstraction
C. Inheritance
D. Polymorphism

Show Answer Answer:-C. Inheritance
Explanation Inheritance allows you to reuse your already written code by inheriting the properties of written code into other parts of the code, hence allowing you to reuse the already written code.

Q 7. Which of the following explains Polymorphism?
A. int func(int, int); float func1(float, float);

B. int func(int); int func(int);

C. int func(float); float func(int, int, char);

D. int func(); int new_func();

Show Answer Answer:-C. int func(float); float func(int, int, char);
Explanation Polymorphism means overriding the same function by changing types or number of arguments. So we have only two options which has the same function names, but as one can observe that in one option types, name and number of parameters all are same which will lead to an error. Hence that is wrong so the option having same name and different types or number of parameters is correct.

Q 8. Wrapping data and its related functionality into a single entity is known as _____________
A. Abstraction
B. Polymorphism
C. Encapsulation
D. Modularity

Show Answer Answer:-C. Encapsulation
Explanation In OOPs, the property of enclosing data and its related functions into a single entity(in C++ we call them classes) is called encapsulation.

Q 9. How structures and classes in C++ differ?
A. In Structures, members are public by default whereas, in Classes, they are private by default
B. In Structures, members are private by default whereas, in Classes, they are public by default
C. Structures by default hide every member whereas classes do not
D. Structures cannot have private members whereas classes can have

Show Answer Answer:-A. In Structures, members are public by default whereas, in Classes, they are private by default
Explanation Structure members are public by default whereas, class members are private by default. Both of them can have private and public members.

Q 10. What does polymorphism in OOPs mean?
A. Concept of allowing overiding of functions
B. Concept of hiding data
C. Concept of keeping things in differnt modules/files
D. Concept of wrapping things into a single unit

Show Answer Answer:-A. Concept of allowing overiding of functions
Explanation In OOPs, Polymorphism is the concept of allowing a user to override functions either by changing the types or number of parameters passed.

Posted

in

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

You cannot copy content of this page