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.

Which data type is most suitable for storing a character in C++?

  • Char
  • Float
  • Int
  • String
The 'char' data type is most suitable for storing a single character in C++. It can hold characters like 'A', 'B', '1', '$', etc.

The data type ______ is used to store boolean values in C++.

  • bool
  • char
  • float
  • int
In C++, the bool data type is used to store boolean values, which can be either true or false. This data type is fundamental for representing conditions and making decisions in programs.

What is the main advantage of using inline functions?

  • Better code organization
  • Enhanced code readability
  • Improved performance
  • Reduced memory usage
The main advantage of using inline functions is improved performance. By requesting the compiler to insert the function code directly at the calling point, you can reduce the overhead of function calls, leading to faster execution in certain situations. However, it's essential to use inline functions judiciously, as they can increase code size if used excessively.

Emily is working with bitwise operations and wants to set a specific bit of an integer variable to 1. Which operator would help her achieve this?

  • AND
  • Bitwise Shift
  • OR
  • XOR
Emily should use the XOR (^) operator to set a specific bit of an integer variable to 1. XOR toggles the bit's value without affecting other bits.

In C++, which of the following groups of operators have the same level of precedence?

  • * and /
  • + and -
  • < and >
  • == and !=
In C++, the == (equality) and != (inequality) operators have the same level of precedence. This means that expressions involving these operators are evaluated from left to right, and they have equal precedence when compared to each other.

The ______ loop in C++ is unique because it evaluates its condition after executing the loop body, ensuring the loop body runs at least once.

  • do-while
  • for
  • if
  • while
The do-while loop in C++ is distinctive because it guarantees that the loop body will execute at least once. It first executes the loop body and then evaluates the condition. This behavior is useful when you want to ensure that a certain piece of code runs before checking the loop condition.

Robert is working on financial software and needs to store very precise values for currency calculations. Which data type should he consider?

  • decimal
  • double
  • float
  • long double
Robert should consider using the decimal data type in C#. Unlike float and double, which are floating-point types and have limited precision, decimal provides high precision and is suitable for financial calculations where accuracy is crucial. It can represent numbers with up to 28-29 significant digits, making it ideal for handling currency values.

In C++, the operator ______ is used to fetch the value of the object or variable located at the address specified by its operand.

  • &
  • *
  • ->
  • ::
In C++, the "->" operator is known as the member access operator and is used to fetch the value of the object or variable located at the address specified by its operand. It's commonly used to access members of objects pointed to by pointers. For example, if you have a pointer to a class instance, you can use "->" to access its members.