Programming MCQs

MCQ on C++ Programming Language set-7

Pinterest LinkedIn Tumblr
This set of MCQ on C++ programming language includes collections of multiple-choice questions on fundamentals of C++ programming. It includes MCQ on inheritance in C++, constructor, and destructor in a class, base class, derived class, template class, and nested class used in the C++ Programming language.

1. What is required in inheritance to initialize the data members of the base class through derived class?
A) Object declaration
B) Destructor
C) Constructor
D) Inheritance

2. In which case is it mandatory to provide a destructor in a class?
A) Almost in every class
B) Class for which two or more than two objects will be created
C) Class for which copy constructor is defined
D) The class whose objects will be created dynamically

3. Which of the statements is true in a protected derivation of a derived class from a base class?
A) Private members of the base class become protected members of the derived class
B) Protected members of the base class become public members of the derived class
C) Public members of the base class become protected members of the derived class
D) Protected derivation does not affect private and protected members of the derived class

4. When the access specifier of the base class in the derived class definition is public, the base class is ..
A) Publicly inherited
B) Protectively inherited
C) Privately inherited
D) None of the above

5. A pointer to the base class can hold the address of
A) only base class object
B) only derived class object
C) base class object as well as derived class object
D) None of the above

Read Also: MCQ on c++ Programming with Answers

6. A template class
A) is designed to be stored in different containers
B) works with different data types
C) generates objects which must be identical
D) generates classes with different numbers functions

7. The constructor and the destructor of a class are automatically invoked when memory is allocated and deallocated to an…
A) Data type
B) Copy constructor
C) Object
D) None of the above

8. A pure virtual function is a virtual function that
A) has nobody
B) returns nothing
C) is used in the base class
D) both (A) and (C)

9. A class defined within another class is
A) Nested Class
B) Inheritance
C) Containership
D) Encapsulation

10. Which variable stores the memory address of another variable?
A) Reference
B) Pointer
C) Array
D) None of the above

Answers:

1. What is required in inheritance to initialize the data members of the base class through derived class?
C) Constructor

2. In which case is it mandatory to provide a destructor in a class?
D) A class whose objects will be created dynamically

3. Which of the statements is true in a protected derivation of a derived class from a base class?
C) Public members of the base class become protected members of the derived class

4. When the access specifier of the base class in the derived class definition is public, the base class is…
A) Publicly inherited

5. A pointer to the base class can hold the address of
C) base class object as well as derived class object

6. A template class
B) works with different data types

7. The constructor and the destructor of a class are automatically invoked when memory is allocated and deallocated to an…
C) Object

8. A pure virtual function is a virtual function that
D) both (A) and (C)

9. A class defined within another class is
A) Nested Class

10. Which variable stores the memory address of another variable?
B) Pointer

Read Next: MCQ On C++ Tokens Expressions And Control Structure Part-1

Author

Shuseel Baral is a web programmer and the founder of InfoTechSite has over 8 years of experience in software development, internet, SEO, blogging and marketing digital products and services is passionate about exceeding your expectations.

Comments are closed.