In C++, function overloading is resolved at _______. 

  • runtime 
  • declaration time 
  • compile-time 
  • execution-time
Function overloading allows multiple functions in the same scope to have the same name as long as they have different parameter lists. In C++, the appropriate overloaded function is chosen at compile-time based on the function call's arguments.

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.

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.

What is the size (in bytes) of an int data type in most C++ implementations? 

  • 1 
  • 2 
  • 4 
  • 8
In most C++ implementations, particularly those that follow the x86 architecture and many 32-bit systems, an int data type occupies 4 bytes in memory. However, it's essential to note that the size can vary based on the platform and compiler.

What is the initial statement in a for loop typically used for? 

  • Incrementing 
  • Condition check 
  • Initialization 
  • Loop termination
In a for loop, the initial statement is typically used for initialization purposes. This is where variables, often loop counters, are initialized before the loop begins its execution.

What is the main purpose of using friend functions in C++? 

  • To increase the execution speed of programs 
  • To enhance object-oriented principles 
  • To achieve data encapsulation and abstraction 
  • To provide access to class's private and protected members from outside the class
While C++ uses classes and objects to encapsulate data and behavior, there are cases where you might want an external function (not belonging to the class) to access the private or protected members of the class. This is where friend functions come into play. They provide an exception to the usual encapsulation rules.

The diamond problem occurs due to _______ and can be resolved using _______. 

  • inheritance, interfaces 
  • encapsulation, templates 
  • multiple inheritance, virtual inheritance 
  • overloading, namespaces
The diamond problem is a complication that arises from multiple inheritance when two classes B and C inherit from A, and class D inherits from both B and C. If there is a method in A that B and C have overridden, and D does not override it, then which version of the method does D inherit: that of B, or that of C? This ambiguity can be resolved in C++ using virtual inheritance, ensuring that only one instance of the base class exists in the derived class.

In C++, a size of long double is at least _______ bytes. 

  • 8 
  • 10 
  • 12 
  • 16
In C++, the size of long double is compiler-dependent. However, according to the C++ standard, it is at least 8 bytes or the size of a double, whichever is greater. Some compilers may allocate more.