How does C++ handle the virtual table in a multiple-inheritance scenario? 

  • Single table for all classes 
  • Separate tables for each base class 
  • A combination of both depending on visibility 
  • Virtual tables are not used
In C++, when a class inherits from multiple base classes, each base class will have its own virtual table. Thus, an object of the derived class will have separate virtual tables for each inherited class to handle dynamic dispatch for function calls, ensuring correct method resolution.

The members of a struct are _______ by default. 

  • private 
  • public 
  • protected 
  • static
In C++, the members of a structure (struct) are public by default. This means they can be accessed from functions outside the structure. This is in contrast to the members of a class, which are private by default and cannot be accessed or viewed outside of the class.

In C++, the data type _______ is commonly used to store large integers. 

  • float 
  • char 
  • long long int 
  • double
In C++, the long long int data type is designed to store very large integers. It can typically store at least 64 bits, allowing for a wide range of integer values far beyond the standard int.

How can a function indicate that it will not throw any exceptions? 

  • By using the noexcept specifier 
  • By returning a null pointer 
  • By using the try block without catch 
  • By marking it as static
The noexcept specifier in C++11 and later indicates that a function does not throw exceptions. If such a function does throw an exception, the program will terminate (usually by calling std::terminate). This can be a useful optimization hint for the compiler.

Which data type would be most appropriate for storing a boolean value? 

  • int 
  • char 
  • double 
  • bool
The bool data type is specifically designed in C++ to store boolean values, which can be either true or false. Using other data types like int, char, or double for boolean values would be inefficient and not semantically clear. Thus, bool is the most appropriate choice for this purpose.

Consider enum class in C++11 and above. Which of the following is a true statement about its functionality? 

  • It allows for automatic type conversion. 
  • It cannot be forward declared. 
  • It restricts the scope of the enumerator values to the enumeration. 
  • It cannot be used with switch statements.
In C++11 and later, enum class (or "strongly typed enumerations") was introduced. Unlike traditional enums, the enumerators of an enum class are not exported to the surrounding scope, thus preventing name clashes. This essentially gives them a "scoped" behavior. This feature enhances type safety and code clarity.

Consider a large-scale software project that heavily utilizes templates and generic programming. With an impending deadline, the compilation time is becoming a significant bottleneck. Which C++ feature/technique might be best suited to reduce compilation times without altering runtime performance? 

  • Decrease template depth 
  • Explicit template instantiation 
  • Use dynamic polymorphism
  • Use of inline functions 
Explicit template instantiation can help reduce compilation times by instructing the compiler to instantiate the templates in a specific source file rather than whenever they're used. This can help reduce redundancy and speed up the compilation of large projects that heavily rely on templates.

What is a friend function in C++? 

  • A function that always returns a friend object. 
  • A private function of a class. 
  • A function that can access private members of a class. 
  • A function that can only be called within its class.
A friend function in C++ is a special function that, although not a member of a class, has access to its private and protected members. This is used to allow non-member functions and other classes to access such members.

If a break statement is encountered in a nested loop, it will exit _______. 

  • the outermost loop 
  • the innermost loop 
  • the function 
  • the program
When a break statement is encountered within a nested loop, it only exits the loop in which it's directly contained, i.e., the innermost loop. It does not affect any outer enclosing loops.

How does C++ treat an enum regarding its type and size? 

  • As a float type with fixed size 
  • As an integer type with variable size 
  • As a class with member functions 
  • As a boolean type
Enums in C++ are treated as integer types. Their actual size can vary based on the compiler and the number of values they hold, but typically, they have the size of an int. C++11 introduced scoped enumerations (enum class) that offer better type safety, but fundamentally, they're still integers.

The first commercially available C++ compiler was named _______. 

  • CFront
  • Clang 
  • GCC 
  • Turbo C++ 
CFront was the first commercially available C++ compiler. It was developed by Bjarne Stroustrup at Bell Labs as a front-end to the C compiler. This compiler played a crucial role in the early evolution and popularization of C++.

In the context of floating-point representation, what is the role of the mantissa? 

  • Determines the sign 
  • Determines the exponent 
  • Stores the actual digits 
  • Determines the base
In floating-point representation, the number is typically represented as: (-1)^sign * mantissa * (base^exponent). The mantissa is responsible for storing the actual digits of the floating-point number, while the exponent determines the position of the decimal point and the sign determines its sign.