The process by which the correct function is selected from a set of overloaded functions during compile time is termed as ______.

  • Function Invocation
  • Function Overloading
  • Function Overriding
  • Function Resolution
The process by which the correct function is selected from a set of overloaded functions during compile time is termed as Function Resolution. It is the compiler's job to determine which overloaded function to call based on the arguments provided. This ensures type safety and efficiency in function calls.

The presence of default arguments can sometimes lead to ambiguities in _________ resolution.

  • Function Overloading
  • Inheritance
  • Operator Overloading
  • Type Casting
Default argument values can cause ambiguities in function overloading when multiple overloaded functions have similar parameter lists, and it becomes unclear which function should be called.

John is creating a game and needs a variable to store whether a player is alive or dead. Which data type is most appropriate for this purpose?

  • bool
  • char
  • decimal
  • double
John should use the 'bool' (boolean) data type. Booleans are binary, representing either 'true' or 'false'. They are perfect for storing states like 'alive' or 'dead' in a game, allowing for simple condition checks.

Lisa is trying to divide 15 by 2 and get an integer result. Which operator should she use in C++?

  • /
  • %
  • //
  • ÷
In C++, to perform integer division and get the quotient as an integer result, Lisa should use the '/' operator. The '%' operator is used to calculate the remainder in integer division. The other options are not valid C++ operators for division.

Peter is developing a program where he wants to repeatedly ask the user for input until the user provides a valid response. Which loop should Peter use?

  • do-while loop
  • for loop
  • switch loop
  • while loop
Peter should use a while loop in this scenario. A while loop repeatedly executes a block of code as long as a given condition is true. It's suitable for situations where the program needs to keep asking for input until a certain condition is met, such as validating user input.

James sees that two functions with identical names and parameters exist in a program. However, they perform different operations. He initially thinks it's function overloading. What misconception does he have about function overloading?

  • Function overloading allows multiple functions with the same name and different parameters
  • Function overloading allows multiple functions with the same name and same parameters
  • Function overloading is not related to function names
  • Function overloading requires different return types
James has a misconception about function overloading. Function overloading allows multiple functions with the same name but different parameters. It's the difference in parameter types or the number of parameters that distinguishes overloaded functions, not the name alone.

Robert wants to write a function that can either accept two parameters or three. What feature of C++ should he use to achieve this?

  • Function Overloading
  • Function Pointers
  • Function Templates
  • Inheritance
Robert should use Function Overloading in C++ to write a function that can accept either two or three parameters. Function Overloading allows a programmer to define multiple functions with the same name but different parameter lists. When Robert calls the function with two parameters, one version of the function is invoked; when he calls it with three parameters, a different version is invoked, providing flexibility and reusability in his code.

Where should the default values of the parameters be specified?

  • In a separate header file
  • In the function call
  • In the function declaration
  • In the function definition
Default values of parameters in C++ functions should be specified in the function definition, not in the declaration. This is where you provide the actual implementation of the function, including the default values for its parameters. The declaration merely informs the compiler about the function's signature.

In a switch-case structure, if a case does not have the break keyword, the subsequent cases or blocks will execute until this keyword is encountered.

  • Continue
  • End
  • Skip
  • Stop
In a switch-case structure, if a case does not have the break keyword, it will fall through to the subsequent cases or blocks until a break is encountered. The break keyword is essential to exit the switch statement once a case is matched and executed.

Jack has written a C++ program, but when he tries to run it, nothing appears on the screen. What could be missing in his main function?

  • #include directive
  • cout << "Hello, World!" << endl; statement
  • int main() function
  • return 0; statement
Jack might be missing the cout << "Hello, World!" << endl; statement within his main() function. Without this line, nothing will be displayed on the screen when he runs the program.