This document will contain 20 Multiple Choice Questions (MCQs) covering important C++ topics
discussed so far (Functions, Default Arguments, Function Overloading, Classes & Objects,
Constructors, Destructors, Access Modifiers). I will prepare both DOCX and PDF versions,
maintaining anonymity.
C++ Topic-Wise Quiz (20 MCQs)
Instructions: Choose the best answer for each question.
1. Functions
1. Which of the following is the primary benefit of using functions in C++? a) Makes code run
faster b) Improves code reusability and modularity c) Reduces compilation time d) Directly
protects data from unauthorized access
2. What does a function prototype (declaration) typically tell the compiler? a) The exact logic
inside the function b) The function's name, return type, and parameters c) How many
times the function will be called d) The memory address where the function is stored
3. A function that does not return any value should have which return type? a) int b) null c)
void d) none
2. Default Arguments
1. In C++, where must default arguments be placed in a function's parameter list? a)
Anywhere in the list b) From left to right c) From right to left d) Only for the first parameter
2. Can you specify default arguments in both the function declaration and its definition? a)
Yes, always b) No, only in the declaration OR definition, not both c) Yes, but only if the
default values are different d) Only for void functions
3. Which of the following function declarations is invalid based on default argument rules?
a) void func(int a, int b = 0); b) void func(int a = 0, int b = 1); c) void func(int a = 0, int b); d)
void func(int a, int b = 0, int c = 1);
3. Function Overloading
1. What allows multiple functions in C++ to have the same name but different functionalities?
a) Function overriding b) Function recursion c) Function overloading d) Function aliasing
2. Which of the following is NOT considered part of a function's signature for overloading
purposes? a) Function name b) Number of parameters c) Type of parameters d) Return
type
3. If you have two functions: int calculate(int x, int y) and double calculate(double x, double
y), which one will be called by calculate(5, 10)? a) int calculate(int x, int y) b) double
calculate(double x, double y) c) It will cause a compile-time error d) It depends on the
compiler optimization
4. Classes & Objects
1. A class in C++ is best described as a: a) Variable that holds multiple values b) Blueprint
or template for creating objects c) Function that performs a specific task d) Pre-defined
data type by the C++ standard library
2. An object is an ____ of a class. a) identifier b) declaration c) instance d) type
3. Which operator is used to access members (data or functions) of an object? a) :: (Scope
resolution operator) b) -> (Arrow operator, for pointers) c) . (Dot operator) d) =
(Assignment operator)
5. Constructors & Constructor Overloading
1. What is the main purpose of a constructor in C++? a) To deallocate memory when an
object is destroyed b) To initialize an object's data members when it is created c) To
perform a specific task on an object during its lifetime d) To return a value from a class
function