C++ Multiple Choice Questions
C++ Multiple Choice Questions
2. OOP Paradigm:
3. Advantages of OOP:
Answer: B) Subclass
4. Which concept allows for the same method name to behave differently based on
the object that is calling it? A) Encapsulation
B) Inheritance
C) Polymorphism
D) Abstraction
Answer: C) Polymorphism
Answer: B) Inheritance
Answer: C) Class
7. In exception handling, which block is used to execute code that may cause an
error? A) catch
B) finally
C) try
D) throw
Answer: C) try
Answer: C) myVariable
Answer: C) const
Answer: C) string
Answer: C) 25
Answer: A) &
7. Which of the following statements correctly declares a variable in C++? A) int
1stNumber;
B) float number;
C) string my variable;
D) char@character;
Answer: B) %
10. Which of the following input statements is used to read a value from the user in
C++? A) scanf
B) cin
C) input
D) read
Answer: B) cin
Given the expression x = (a > b) ? a : b;, what does it represent? A) A traditional if-
else statement
B) A switch-case statement
C) A ternary conditional operator
D) A loop iteration
3. Which of the following types of functions does not return a value? A) Void
functions
B) Value-returning functions
C) Recursive functions
D) Overloaded functions
Answer: B) &
7. In the context of recursion, what is a base case? A) A condition that causes infinite
recursion
B) The simplest case that can be solved without further recursion
C) A condition that leads to program termination
D) The first recursive call made by a function
Answer: B) The simplest case that can be solved without further recursion
cpp
Higher-Order Thinking MCQs on Functions and Parameter Passing in C++
Answer: B) To inform the compiler about the function's return type and parameters
4. Why is recursion often preferred for solving problems like factorial calculation
or Fibonacci series? A) It uses less memory than iterative solutions
B) It provides a clearer and more elegant solution for problems that have a recursive
structure
C) Recursive solutions are always faster than iterative ones
D) It eliminates the need for function prototypes
Answer: B) It provides a clearer and more elegant solution for problems that have a
recursive structure
5. What happens if the base case is not properly defined in a recursive function? A)
The function will return an undefined value
B) The function may cause a stack overflow due to infinite recursion
C) The program will terminate unexpectedly
D) The function will execute normally but will not return a value
Answer: B) The function may cause a stack overflow due to infinite recursion
Answer: C) Changes to result within the function will affect the original variable
passed as an argument
Answer: C) Function overloading allows multiple functions with the same name but
different parameter types or counts
8. In a function that uses both pass-by-value and pass-by-reference, how can you
ensure that the original value of a variable remains unchanged? A) Use only
pass-by-reference for all parameters
B) Use pass-by-value for parameters that should not change
C) Always return a new value from the function
D) Avoid using function prototypes
9. If a recursive function is designed to compute a value but does not have a return
type specified, what will the compiler assume? A) The function will be treated as a
void function
B) The function will produce a compilation error
C) The function will return an integer by default
D) The function will return a floating-point number
10. What is the purpose of the break statement inside a loop? A) To terminate the
program
B) To skip the current iteration and move to the next
C) To exit the loop immediately
D) To continue executing the loop even if the condition fails
11. Answer: C) To exit the loop immediately
12. In nested loops, what is the effect of using a continue statement? A) It exits
the outer loop
B) It skips the remaining code in the inner loop and continues with the next iteration
of the inner loop
C) It skips the next iteration of the outer loop
D) It causes a compilation error
13. Answer: B) It skips the remaining code in the inner loop and continues with the next
iteration of the inner loop
14. How does using do-while differ from while when controlling loop execution?
A) do-while checks the condition before executing the loop body
B) do-while guarantees at least one execution of the loop body
C) while cannot be used with complex conditions
D) There is no difference; both are identical in function
15. Answer: B) do-while guarantees at least one execution of the loop body
16. Which of the following statements best describes the impact of using multiple
conditional expressions? A) It decreases the performance of the program
significantly
B) It can make the code more complex and harder to read if not structured properly
C) It automatically optimizes the code execution
D) It ensures that all conditions will be evaluated regardless of short-circuit evaluation