C++ Programming Questions and Answers – OOPs – 2

This set of C++ Programming Multiple Choice Questions & Answers (MCQs) focuses on “OOPs – 2”.

1. Which of the following class allows to declare only one object of it?
a) Abstract class
b) Virtual class
c) Singleton class
d) Friend class
View Answer

Answer: c
Explanation: Singleton class allows the programmer to declare only one object of it, If one tries to declare more than one object the program results into error.

2. Which of the following is not a type of Constructor?
a) Friend constructor
b) Copy constructor
c) Default constructor
d) Parameterized constructor
View Answer

Answer: a
Explanation: Friend function is not a constructor whereas others are a type of constructor used for object initialization.

3. Which of the following is correct?
a) Base class pointer object cannot point to a derived class object
b) Derived class pointer object cannot point to a base class object
c) A derived class cannot have pointer objects
d) A base class cannot have pointer objects
View Answer

Answer: b
Explanation: C++ does not allow a derived class pointer to point a base class pointer whereas Base class can point to a derived class object. Both base class and derived class can have pointer objects.
advertisement
advertisement

4. Out of the following, which is not a member of the class?
a) Static function
b) Friend function
c) Constant function
d) Virtual function
View Answer

Answer: b
Explanation: Friend function is not a member of the class. They are given the same access rights as the class member function have but they are not actual members of the class.

5. What is the other name used for functions inside a class?
a) Member variables
b) Member functions
c) Class functions
d) Class variables
View Answer

Answer: b
Explanation: Functions of a class are also known as member functions of a class.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. Which of the following cannot be a friend?
a) Function
b) Class
c) Object
d) Operator function
View Answer

Answer: c
Explanation: Objects of any class cannot be made a friend of any other or same class whereas functions, classes and operator functions can be made a friend.

7. Why references are different from pointers?
a) A reference cannot be made null
b) A reference cannot be changed once initialized
c) No extra operator is needed for dereferencing of a reference
d) All of the mentioned
View Answer

Answer: d
Explanation: References cannot be made null whereas a pointer can be. References cannot be changed whereas pointers can be modified.
Pointers need * operator to dereference the value present inside it whereas reference does not need an operator for dereferencing.
advertisement

8. Which of the following provides a programmer with the facility of using object of a class inside other classes?
a) Inheritance
b) Composition
c) Abstraction
d) Encapsulation
View Answer

Answer: b
Explanation: The concept of using objects of one class into another class is known as Composition.

9. How many types of polymorphism are there in C++?
a) 1
b) 2
c) 3
d) 4
View Answer

Answer: b
Explanation: There are two types of polymorphism in C++ namely run-time and compile-time polymorphisms.
advertisement

10. How run-time polymorphisms are implemented in C++?
a) Using Inheritance
b) Using Virtual functions
c) Using Templates
d) Using Inheritance and Virtual functions
View Answer

Answer: d
Explanation: Run-time polymorphism is implemented using Inheritance and virtual in which object decides which function to call.

11. How compile-time polymorphisms are implemented in C++?
a) Using Inheritance
b) Using Virtual functions
c) Using Templates
d) Using Inheritance and Virtual functions
View Answer

Answer: c
Explanation: Compile-time polymorphism is implemented using templates in which the types(which can be checked during compile-time) are used decides which function to be called.

12. Which of the following is an abstract data type?
a) int
b) float
c) class
d) string
View Answer

Answer: c
Explanation: Class is used as an abstract data type as it can be used to give implementation independent view whereas no other data type can be used to provide this.

13. Which concept means the addition of new components to a program as it runs?
a) Data hiding
b) Dynamic binding
c) Dynamic loading
d) Dynamic typing
View Answer

Answer: c
Explanation: Dynamic loading is the concept of adding new components to a program as it runs.

14. Which of the following explains the overloading of functions?
a) Virtual polymorphism
b) Transient polymorphism
c) Ad-hoc polymorphism
d) Pseudo polymorphism
View Answer

Answer: c
Explanation: Ad-hoc polymorphism is a type of polymorphism in which a function denotes heterogeneous implementation depending upon the types of argument.

15. Which of the following approach is used by C++?
a) Top-down
b) Bottom-up
c) Left-right
d) Right-left
View Answer

Answer: b
Explanation: C++ is an object-oriented language and OOL uses a bottom-up approach to solve/view a problem.

Sanfoundry Global Education & Learning Series – C++ Programming Language.

To practice all areas of C++ language, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.