Which bitwise operator is used to flip the bits (change 1s to 0s and vice versa) of a binary number? 

  • ~
The ~ operator is the bitwise NOT operator in C++. It inverts each bit of a number, changing 1s to 0s and 0s to 1s. & is the bitwise AND, | is the bitwise OR, and ^ is the bitwise XOR operator.

The standard namespace used commonly in C++ is _______. 

  • conio
  • iostream 
  • stdlib 
  • std 
In C++, the "std" stands for the standard namespace. A namespace is a declarative region that provides a scope to the identifiers inside it. Using the "std" namespace, we can access features of the C++ Standard Library without prepending their names with std:: each time.

What is the potential risk of using exception specifications like throw(type)? 

  • It can lead to unpredictable behavior 
  • It improves program efficiency 
  • It catches all types of exceptions 
  • It ensures type safety in exceptions
Using exception specifications like throw(type) can lead to unpredictable behavior if a different type of exception is thrown. In C++11 and later, these exception specifications are deprecated in favor of noexcept. If a function with a dynamic exception specification throws an exception not listed, it will call std::unexpected().

Which standard library provides predefined exception classes in C++? 

  •  
  •  
  •  
The standard library in C++ provides a set of predefined classes that represent standard exception types. Developers can leverage these classes to catch common errors or even derive their own custom exception types from these base classes.

What is the purpose of a conversion constructor in C++? 

  • To convert one class type to another 
  • To convert data types during inheritance 
  • To oversee object destruction 
  • To convert other data types to the class type
In C++, a conversion constructor is a single-parameter constructor that allows the implicit or explicit conversion of an argument type to the class type. It enables a seamless conversion of one data type (often built-in types) to the type of the class being defined.

A _______ block is used to enclose the code that might throw an exception. 

  • loop 
  • function 
  • try 
  • class
In C++, the try block is used to wrap the code that might throw an exception. If any part of the code inside the try block throws an exception, the execution immediately shifts to the corresponding catch block to handle the exception, if a matching catch exists.

You are implementing a recursive algorithm and observe that it recalculates the same values multiple times, leading to inefficient execution. What technique might be most effective in reducing the redundant calculations? 

  • Use an iterative process. 
  • Increase the memory allocation for the algorithm. 
  • Use memoization. 
  • Optimize data input methods.
When a recursive algorithm recalculates the same values repeatedly, it leads to unnecessary computational overhead. Memoization is a technique where you store the results of expensive function calls and return the cached result when the same inputs occur again, preventing redundant calculations. This is especially useful in recursive algorithms like those seen in dynamic programming.

The ASCII value of 'A' in decimal is _______. 

  • 64 
  • 65 
  • 66 
  • 67
The ASCII value for the uppercase letter 'A' is 65 in decimal. ASCII (American Standard Code for Information Interchange) assigns each character a unique number between 0 and 127.

The break statement cannot be used within a _______. 

  • function 
  • switch statement 
  • class 
  • if condition
The break statement is primarily used to terminate loops and switch statements. Using a break outside these constructs, like directly inside a function without a loop or switch, would result in a compilation error as it wouldn't have a clear context to operate within.

How does the goto statement alter the flow of control in a C++ program? 

  • It repeats the loop indefinitely. 
  • It skips to the next iteration of a loop. 
  • It transfers control to a labeled statement in the code. 
  • It exits the program immediately.
The goto statement in C++ provides an unconditional jump from the goto to a labeled statement found elsewhere in the code. Although it allows for more flexibility in controlling the flow, its overuse or misuse can make the code less readable and more prone to errors. The modern programming paradigm usually discourages its use.