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.

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.

Which of the following best describes the concept of abstraction in C++? 

  • Hiding complex reality while exposing only the necessary. 
  • Protecting data from unauthorized access. 
  • Using single inheritance. 
  • Creating multiple instances of an object.
Abstraction in C++ refers to the concept of hiding the complicated reality of an object while only exposing operations relevant for that object. This allows for simplifying complex systems by breaking them down into smaller, more manageable parts, enabling developers to focus on high-level functionalities.

When a function is called recursively, each call creates a new set of the function's _______. 

  • variables 
  • loops 
  • conditions 
  • headers
Each recursive call creates a new set of the function's local variables. This is maintained in what's called the call stack, where each call has its own memory space.

Some compilers detect tail recursion and optimize it through a technique known as _______. 

  • tail-call optimization 
  • loop unrolling 
  • inline expansion 
  • code compression
Tail-call optimization (or TCO) is a technique where the compiler replaces a function's tail call (a recursive call that's the last thing the function does) with a jump instruction, essentially converting the recursion into iteration and thereby avoiding new stack frame creation.

Which of the following operators cannot be overloaded in C++? 

  • == 
  • :: 
  • ++
In C++, most of the operators can be overloaded with a few exceptions. Among the operators that cannot be overloaded are: the scope resolution operator ::, the member selection operators . and .*, and the ternary conditional operator ?:.

What is the correct syntax for declaring a function that returns an integer? 

  • int functionName; 
  • functionName: int; 
  • int functionName() 
  • int: functionName()
In C++, to declare a function that returns an integer, the correct syntax is "int functionName()". The type "int" signifies that the function's return type is an integer, and the parentheses "()" indicate it's a function declaration. Actual implementation or body of the function would follow the declaration.