To prevent memory leaks, every call to new should be matched with a call to _______. 

  • delete 
  • free 
  • clear 
  • remove
When dynamic memory allocation is done using new, it's necessary to release that memory using delete to prevent memory leaks in C++. This ensures that every byte of memory allocated is properly released, maintaining the health and efficiency of the system.

To achieve runtime polymorphism in C++, _______ are used. 

  • classes 
  • macros 
  • virtual functions 
  • inline functions
Runtime polymorphism in C++ is achieved through the use of virtual functions. These are functions in the base class that you can override in derived classes. The decision about which method to call (the one in the base class or the one in the derived class) is made at runtime, based on the actual type of the object being pointed to, rather than the type of the pointer. This allows for more dynamic behavior and is a core feature of object-oriented programming in C++.

What is the default access specifier for a base class in C++? 

  • private 
  • public 
  • protected 
  • internal
In C++, if you don't specify an access specifier for the members of a class, they are implicitly set to private. This means that they can't be accessed or viewed from objects of the class or any derived class unless friends.

The conditions in a switch-case statement must be of _______ data type. 

  • floating 
  • string 
  • integer or enum 
  • boolean
In a switch-case structure in C++, the conditions or cases must be of an integer or enumeration type. Floating-point and boolean values cannot be used as cases.

When a class contains a pointer to memory allocated in class, we should define a _______. 

  • destructor 
  • constructor 
  • overloader 
  • allocator
When a class contains a pointer that has memory allocated to it dynamically, it's crucial to have a destructor to release that memory when the object is destroyed to prevent memory leaks.

When a continue statement is encountered in a loop, the program control resumes from _______. 

  • next statement 
  • loop condition 
  • beginning of loop 
  • end of loop
The continue statement, when encountered inside a loop, causes the program to skip the rest of the current iteration and move directly to the loop condition to check if the next iteration should commence. In essence, it "continues" to the next iteration of the loop without finishing the current one.

You're developing an embedded system with constrained memory. What should be the main consideration when choosing between using float and double data types? 

  • Precision needs 
  • Popularity of type 
  • Storage size requirement 
  • Arithmetic operations
In embedded systems with memory constraints, storage size becomes a primary concern. A float generally occupies 4 bytes, while a double occupies 8 bytes. Hence, if precision offered by float is acceptable for the application, it would be preferable to use float to save memory space.

Which keyword is used to inherit a class in C++? 

  • import 
  • extend 
  • inherit 
  • public
In C++, inheritance is specified by placing the colon (:) followed by an access specifier (public, protected, or private) and then the name of the base class. The public keyword itself is not used for inheritance, but rather indicates the type of inheritance.

In situations where the argument should not be modified, passing by _______ is preferable to ensure the original data remains unaltered. 

  • value 
  • reference 
  • name 
  • pointer
Passing by value means the function receives a copy of the argument. As a result, any changes made to the parameter within the function don't affect the original data, ensuring it remains unaltered outside the function's scope.

The _______ operator is used to compare whether two C++ values are not equal. 

  • != 
  • == 
  • >= 
  • <=
The != operator in C++ is the "not equal to" operator. It returns true if the operands on either side are not equal. For example, 5 != 3 evaluates to true, while 5 != 5 evaluates to false. The other options represent other comparison operations.