How does the continue statement affect the execution of a loop?

  • It pauses the loop temporarily.
  • It restarts the loop from the beginning.
  • It skips the current iteration and continues with the next iteration.
  • It terminates the loop immediately.
The continue statement in a loop skips the current iteration and continues with the next iteration. It does not terminate the loop or restart it. This is useful when you want to skip certain iterations based on a condition but continue the loop.

The ______ operator is overloaded to perform array subscripting.

  • ()
  • ->
  • =
  • []
The [] operator is overloaded to perform array subscripting in C++. This allows you to access individual elements of an array or a user-defined data structure as if it were an array. Overloading [] enables custom behavior when indexing objects.

David is noticing that a certain piece of computation inside his loop doesn't need to be executed every iteration. What can he use to skip that computation for specific iterations?

  • continue statement
  • for loop
  • if statement
  • switch statement
David can use the continue statement to skip a certain piece of computation for specific iterations within his loop. When continue is encountered, it causes the program to skip the remaining code within the current iteration and move on to the next iteration of the loop. This can improve the efficiency of the loop when certain conditions don't require the computation to be executed.

Max wants to compare two integers to see if they are not equal. Which operator will allow him to do this?

  • !=
  • <=
  • ==
  • >=
Max can use the '!=' (not equal) operator to compare two integers and check if they are not equal. The '==' operator is used to check for equality, while the other operators are used for different types of comparisons.

Kimberly is debugging a program where a loop intended to run 10 times is running indefinitely. Which part of the loop should she particularly inspect for possible logical errors?

  • Loop body
  • Loop condition
  • Loop increment
  • Loop initialization
Kimberly should inspect the loop condition. If the loop condition is not properly defined or is always true, the loop will run indefinitely. She should ensure that the condition is correctly set to run the loop the intended number of times (in this case, 10).

Overloading works in tandem with ______, a feature of OOP, that allows entities to take on more than one form.

  • Abstraction
  • Encapsulation
  • Inheritance
  • Polymorphism
Overloading works in tandem with Polymorphism, a feature of Object-Oriented Programming (OOP), that allows entities to take on more than one form. Polymorphism enables the selection of the appropriate function or behavior at runtime, enhancing code flexibility and reusability. Function overloading is an example of compile-time polymorphism.

In what scenarios should the use of inline functions be avoided?

  • When the function contains loops.
  • When the function is complex and large.
  • When the function is frequently called with a small amount of code.
  • When the function is used in a performance-critical section of code.
Inline functions should be avoided in scenarios where the function is complex and large. The purpose of inline functions is to reduce function call overhead, but in the case of large or complex functions, inlining can lead to code bloat, impacting performance and code maintainability. In such cases, it's better to use regular functions.

Is it possible to specify default arguments only for some middle arguments in a function, skipping the last ones?

  • Default arguments can only be specified for the first arguments.
  • Default arguments can only be specified for the last arguments.
  • No, default arguments must be specified for all or none of the function's arguments.
  • Yes, default arguments can be specified for middle arguments.
In C++, you can specify default arguments for some middle arguments while skipping the last ones. However, all arguments to the right of a default argument must also have default values.

If a function is declared multiple times but defined only once, will the program compile successfully?

  • It depends on the compiler
  • It depends on the function name
  • No
  • Yes
Yes, if a function is declared multiple times but defined only once in a program, it will compile successfully. This is because function declarations inform the compiler about the function's signature and return type, allowing it to check for consistency when the function is called in different parts of the code. The definition provides the actual implementation.

Diane observed that even after explicitly marking a function as inline, the compiler did not inline it. What factors might the compiler consider when making this decision?

  • CPU clock speed, available RAM, function parameters, code comments
  • Compiler version, variable scope, CPU architecture, function visibility
  • Data types used in the function, available disk space, code organization, compiler brand
  • Function complexity, compiler optimization settings, available memory, function size
The decision of whether to inline a function is influenced by various factors. These include the complexity of the function, compiler optimization settings, available memory, and the size of the function. If the function is too complex or exceeds a certain size, the compiler may choose not to inline it, even if marked as such.

Given the expression a = b = c, which assignment is evaluated first?

  • Evaluation Order is Not Defined
  • a = b
  • b = c
  • c = a
In C and C++, assignment operators associate right-to-left. So, b = c is evaluated first, assigning the value of c to b, and then a = b assigns the value of b to a. This behavior is consistent with other binary operators in these languages.

The ternary operator, represented as ? :, can serve as a shorthand for a simple if-else statement.

  • ?else
  • ?if
  • ?then
  • ?when
The ternary operator, represented as ? :, provides a shorthand way to express a simple if-else statement. It evaluates a condition and returns one of two values depending on whether the condition is true or false. This concise syntax is often used to make code more compact and readable.