Which keyword is used in C++ to make a function virtual? 

  • static 
  • const 
  • virtual 
  • override
The keyword virtual is used in C++ to make a function virtual. When a function is declared as virtual, it can be overridden in any derived class. This allows for dynamic polymorphism, where the decision on which method version to execute is made at runtime based on the object's actual type.

Which of the following statements about the if-else control structure is true? 

  • It can only test for numeric conditions. 
  • It executes the else block if the if condition is true. 
  • It allows for multiple conditions to be checked in sequence. 
  • It requires both if and else parts.
The if-else control structure in C++ provides a way to perform decision-making operations. If the condition inside the 'if' block evaluates to true, the 'if' block of code is executed; otherwise, the 'else' block is executed, if present. It can be used to check multiple conditions in sequence by nesting or using "else if".

The shared_ptr in C++ uses _______ counting to manage the memory of shared objects. 

  • reference 
  • object 
  • allocation 
  • array
shared_ptr uses reference counting, which means it keeps a count of the number of shared_ptr objects referring to the same memory location. When this count drops to zero (meaning no shared pointers are referring to the object), the memory is automatically deallocated.

What is the relationship between abstraction and interfaces in C++? 

  • Interfaces are concrete implementations of abstraction. 
  • Abstraction is achieved using only interfaces. 
  • Interfaces ensure abstraction but not vice versa. 
  • C++ does not have interfaces.
In C++, there isn't a direct concept of "interfaces" as in some other languages. However, abstract classes with only pure virtual functions can act similarly to interfaces. These ensure abstraction by forcing derived classes to provide concrete implementations, but not all abstractions need to be interfaces.

To get the quotient of a division in C++, we use the _______ operator. 

  • &&
In C++, the forward slash (/) operator is used for division. When used between two integers, it gives the quotient of the division.

Which of the following is true about the complexity of the std::list::remove function? 

  • O(1) 
  • O(log n) 
  • O(n) 
  • O(n log n)
The std::list::remove function has a linear time complexity O(n). This is because it traverses the list once, removing all elements that match a specified value. As it potentially examines all elements, the complexity is linear.

The process of transferring the program control from where the exception was thrown to the catch block is known as _______. 

  • Throwing 
  • Handling 
  • Propagation 
  • Initialization
Propagation refers to the process where after an exception is thrown, it travels up the call stack until it's caught by an appropriate catch block or, if uncaught, the program terminates.

Using templates excessively can lead to an issue known as _______. 

  • recursion 
  • template bloat 
  • overloading 
  • specialization
Excessive use of templates can result in code that has much larger compiled sizes than equivalent non-template code. This phenomenon, where the binary gets bloated due to templates, is known as template bloat.

When an enum is declared, it creates a new _______. 

  • function 
  • data type 
  • variable 
  • class
When an enumeration (enum) is declared in C++, it essentially creates a new user-defined data type. This allows the programmer to define variables of this enumeration type and assign any of its enumerator values to these variables.

Which smart pointer in C++ retains shared ownership of an object through a pointer? 

  • auto_ptr 
  • unique_ptr 
  • weak_ptr 
  • shared_ptr
shared_ptr is a type of smart pointer in C++ that retains shared ownership of an object. This means multiple shared_ptr objects can own the same object, and the object will only be destroyed when the last shared_ptr owning it is destroyed or reset. This helps in preventing memory leaks and ensuring safer memory management.