Which of the following operators has the highest precedence in C++?

  • * (Multiplication)
  • + (Addition)
  • ?: (Ternary Conditional)
  • N/A
The * (Multiplication) operator has the highest precedence in C++. This means that it is evaluated before other operators when multiple operators are used in an expression. Understanding operator precedence is crucial for writing correct and efficient C++ code.

What do you call the process of calling a function in your program?

  • Function Declaration
  • Function Definition
  • Function Invocation
  • Function Prototype
The process of calling a function in your program is known as "Function Invocation" or simply "Calling a Function." This is where you use the function name followed by parentheses to execute the code within the function.

Tom is creating a game where the player's health decreases over time until it reaches zero. To implement this, which loop structure is best suited?

  • Do-While Loop
  • For Loop
  • Foreach Loop
  • While Loop
For Tom's game, a "While Loop" is the best choice. This loop continuously executes a block of code as long as a specified condition is true, making it suitable for decrementing the player's health until it reaches zero.

If no cases match in a switch statement and there's no default clause, then none of the switch blocks will execute.

  • catch
  • final
  • else
  • default
In a switch statement, if no cases match and there's no default clause, none of the switch blocks will execute. The default clause provides a fallback option to handle cases where none of the defined cases match the switch expression.

Which of the following best describes the difference between function declaration and definition?

  • A declaration tells the compiler about the function's name, return type, and parameters, while a definition provides the actual implementation of the function.
  • Declarations and definitions are the same thing.
  • Declarations define the function's behavior, whereas definitions merely declare its existence.
  • Declarations specify where a function can be used, while definitions specify how it should be used.
The primary difference between function declaration and definition lies in their purpose. A declaration informs the compiler about the function's signature, return type, and parameters, allowing the compiler to recognize it when used. On the other hand, a definition provides the actual implementation of the function, specifying what the function does.

Lily is receiving an error that says a particular header file is missing. What part of her program structure might she have forgotten to include?

  • #include Directives
  • Function Prototypes
  • Header Guards
  • using namespace std;
Lily might have forgotten to include the necessary #include directives in her program. These directives are used to include header files, and missing them can result in compilation errors due to undefined references.

Alice is developing a program that should run uniformly across multiple platforms. She is concerned about the size of data types. Which feature of C++ should she explore?

  • Data Type Modifiers
  • Preprocessor Directives
  • Standard Library Features
  • Standard Template Library (STL)
Alice should explore the Data Type Modifiers in C++. Data Type Modifiers like int32_t and int64_t are part of the header and ensure consistent data size across platforms, addressing her concern about data type size and platform uniformity.

Sarah wants to create a menu-driven program where the menu is displayed repeatedly until the user selects the "Exit" option. What control structure can assist her in achieving this?

  • Do-While Loop
  • For Loop
  • If-Else Statements
  • Switch Statement
To create a menu-driven program like Sarah's, the "Do-While Loop" is the most appropriate. It ensures that the menu is displayed at least once and then repeatedly as long as the user doesn't choose the "Exit" option, providing the desired functionality.

If a function parameter has a default argument, must all subsequent parameters also have default arguments?

  • It depends
  • No, never
  • Yes, always
  • Yes, in some cases
No, never. In C++, if a function parameter has a default argument, subsequent parameters are not required to have default arguments. Default arguments allow calling a function with fewer arguments, and the missing arguments will take on their default values.

Which of the following changes will NOT result in a different overloaded function in C++?

  • Changing the data type of parameters
  • Changing the number of parameters
  • Changing the order of parameters
  • Changing the return type of a function
In C++, changing only the return type of a function does not result in a different overloaded function. Overloaded functions are distinguished based on the number or type of parameters, not the return type.