What is the basic idea behind recursion in programming? 

  • Breaking down a problem into smaller steps. 
  • Running a function multiple times. 
  • A function calling itself. 
  • Creating a loop for iteration.
Recursion in programming refers to a technique where a function calls itself to solve a problem. The main idea is to break the problem down into smaller instances of the same problem. This approach allows for solutions to be built incrementally, mirroring mathematical recursion.

How does the logical AND (&&) operator behave when the first operand is false? 

  • It checks the second operand. 
  • It returns false immediately. 
  • It returns true immediately. 
  • It throws an exception.
In C++, the logical AND (&&) operator is "short-circuiting". This means if the first operand is false, it won't even check the second operand because the overall result will definitely be false. This behavior can be used for efficient coding practices.

Which keyword is used to define a function in C++? 

  • class 
  • struct 
  • define 
  • void
In C++, the keyword to define a function isn't necessarily a specific reserved word like "class" or "struct". Instead, functions begin with their return type, such as "void" for functions that don't return any value. But it's worth noting that "void" is just one possible return type, and not strictly a keyword exclusively for function definition.

Imagine you are debugging a C++ application where a certain condition seems to always evaluate to true, even when you expect it not to. What could be a common mistake related to relational operators? 

  • Confusing = with == 
  • Using !== as an inequality operator 
  • Always using > instead of >= 
  • Relying only on the < operator
In C++, the single equals (=) is an assignment operator, meaning it assigns a value to a variable. The double equals (==) is a comparison operator, which checks for equality. A common mistake is to use a single equals sign instead of a double equals sign when trying to compare values, leading to unexpected behavior.

In what year was the C++17 standard released? 

  • 2011 
  • 2014 
  • 2017 
  • 2019
The C++17 standard, commonly referred to as C++17, was released in 2017. It brought several new features and improvements over the previous standards, streamlining the language and enhancing its capabilities for modern software development.

If you want to force floating-point division in C++ when dividing two integers, one of the numbers should be _______. 

  • casted as float 
  • multiplied by zero 
  • negated 
  • subtracted by one
In C++, to force floating-point division when dividing two integers, you can cast one or both of the integers to a floating-point type (like float or double). By doing this, the division will result in a floating-point value, preserving any fractional part. For instance, (float)5 / 2 would result in 2.5 instead of 2.

The memory allocated for a struct is equal to the sum of the memory of its individual members, considering _______. 

  • padding 
  • initialization 
  • inheritance 
  • encapsulation
Memory alignment requirements can cause "padding" between members of a struct, which can increase the total memory size of the struct. This is essential for data to be accessed in an optimized manner on the hardware.

Which keyword is used to catch exceptions in C++? 

  • handle 
  • rescue 
  • catch 
  • secure
In C++, the catch keyword is used to define a block of statements that will be executed when a particular exception is thrown. This block is used to handle the exception and provide a response, ensuring that the program can continue or terminate gracefully.

In C++, an abstract class can have a mix of abstract as well as _______ methods. 

  • concrete 
  • private 
  • static 
  • virtual
An abstract class in C++ can have both abstract methods (methods without any definition) and concrete methods (methods with a definition). This allows for a mix of defined and undefined behaviors in subclasses.

Which type of class inheritance allows a derived class to inherit attributes and methods from more than one base class? 

  • Single 
  • Multilevel 
  • Multiple 
  • Hierarchical
Multiple inheritance in C++ allows a derived class to inherit attributes and methods from more than one base class. This contrasts with single inheritance where a class can inherit only from one superclass. C++ supports multiple inheritance, unlike some other OO languages.