Indirect recursion involves a function calling another function that eventually calls the original function, forming a _______. 

  • cycle 
  • chain 
  • tree 
  • grid
Indirect recursion forms a cycle where function A calls function B (or a series of functions), and eventually, one of those functions calls back to function A. This loop of function calls forms the cycle characteristic of indirect recursion.

In C++, when a parameter is passed by value, what exactly is being passed to the function? 

  • Original value 
  • Memory address 
  • Reference 
  • Copy of the original value
When parameters are passed by value in C++, a copy of the original value is provided to the function. This means the function operates on this copy, and the original data remains unchanged outside the function scope.

In C++, to ensure that a derived class does not override a method of a base class, the method in the base class should be declared as _______. 

  • final 
  • constant 
  • private 
  • static
In C++, when a base class wants to prevent its method from being overridden in the derived classes, it declares that method as final. This ensures that the method retains its original functionality without any modifications.

Consider a scenario where you're building a game that involves a character navigating through a maze with multiple levels. How might the break statement be used effectively in this context? 

  • To immediately exit the game. 
  • To move to the next level when the exit point is reached. 
  • To pause the game for a short period. 
  • To restart the current level.
The break statement is used to exit a loop prematurely. In the context of the game, when the character reaches an exit point of the maze, the loop processing the current level's moves can be exited using the break statement, effectively moving to the next level.

Which keyword is used to define a template in C++? 

  • class 
  • public 
  • private 
  • template
The template keyword is used to define templates in C++. Templates allow functions and classes to operate with generic types, enabling more flexible and reusable code structures.

How can you prevent an object of a C++ class from being copied? 

  • Use private constructors 
  • Make the class abstract 
  • Declare the copy constructor as private 
  • Use an interface
By declaring the copy constructor (and the assignment operator) as private, you ensure that they cannot be invoked from outside the class, effectively preventing the creation of a copy of an object of the class. This is a common technique for the Singleton pattern.

An exception thrown by a function in the _______ block can be caught in the subsequent catch block. 

  • try 
  • throw 
  • return 
  • main
In the 'try' block, we place the code that might throw an exception. Any exception that occurs inside the 'try' block can be caught by the subsequent 'catch' block, allowing for appropriate error handling.

The return statement can be omitted in a function with a return type other than void if _______. 

  • it's a template function 
  • it throws an exception 
  • it's a friend function 
  • it's an inline function
In C++, if a function with a return type other than void does not have a return statement, but throws an exception that exits the function, it's acceptable and will not result in a compilation error.

In C++, _______ is used to restrict access to class members and maintain encapsulation. 

  • public 
  • protected 
  • private 
  • global
The "private" access specifier in C++ restricts access to class members, ensuring they can't be accessed or modified outside the class, thereby maintaining encapsulation and data integrity within the class.

What is the key difference between overriding and overloading a function in C++? 

  • Return type 
  • Number of arguments 
  • Function signature 
  • Polymorphism type
Overloading refers to defining multiple functions with the same name but different signatures (usually different number or type of parameters). Overriding, on the other hand, is related to inheritance and polymorphism where a derived class provides a specific implementation for a method that is already provided by its base class. In overriding, the method in the derived class should have the same name, return type, and parameters as the method in the base class. The key difference is thus related to polymorphism and inheritance for overriding versus method signature differences for overloading.