Jessica is facing issues in her program where virtual functions with default arguments aren't behaving as expected. What should she be careful about while using default arguments with virtual functions?

  • Default Argument Scope
  • Function Overriding
  • Inline Functions
  • Virtual Function Resolution
Jessica should be careful about function overriding when using default arguments with virtual functions. Virtual functions are resolved at runtime based on the actual object's type, and default arguments are resolved at compile-time. This can lead to unexpected behavior if the derived class changes the default argument values.

What will be the result of the expression 5 & 3 in C++?

  • 0
  • 1
  • 15
  • 8
In C++, the '&' operator is a bitwise AND operator. When you perform a bitwise AND operation between 5 and 3 (binary 101 & 011), you get 001, which is decimal 1.

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.

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).

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.

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.

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.

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.

Default arguments should be avoided in virtual functions as they don’t behave as most people expect and can lead to ________.

  • Code Reuse
  • Improved Debugging
  • Increased Performance
  • Runtime Errors
Default arguments in virtual functions can lead to runtime errors because the default argument values are determined at compile-time, not runtime. This can result in unexpected behavior when overriding virtual functions in derived classes.

Anna wants to write a program that counts the number of students in a school. Which data type should she use for the count?

  • bool
  • float
  • int
  • string
Anna should use the 'int' (integer) data type. Integers are used for storing whole numbers, which is ideal for counting discrete items like the number of students. It provides efficient memory usage and supports mathematical operations.