That’s my variable type!
It's a Class Act!
OOPs, I Did It Again
Run Forrest Run!
C++ @ Company
100

Which data type should be used to represent both positive and negative values

A signed integer

100

Which C++ element includes a return type, a name, parentheses, and a code block in curly braces?

Function

100

True/False: A function needs to be declared before all use.

True

100

What does it return?

float x = 7.7; 

int y = x; 

return y;

7

100

True/False: Company does not use C++ exceptions.

True, use error codes and assertions instead.

200

Which of the following is not a primitive (built-in) type in C++?
a. int
b. string
c. bool
d. char
e. void

String

200

What is the return type of a constructor function?

Nothing

200

what is the scope of a protected member variable in C++

Class and its derived classes

200

What does this return?

    int x = 7;

    int &y = x;

    y = 21;

    return x;

21

200

Which of these is a pointer to an object that has multiple owners: std::unique_ptr or std::shared_ptr

std::shared_ptr

300

Are C++ identifiers case sensitive?

Yes, ‘Cat’, ‘cAT’ and ‘CAT’ are different identifiers

300

What is the default access level of a member variable in a C++ class?

Private

300

Two or more functions have the same name but the arguments are different. This is an example of

Function Overloading or Polymorphism

300

What is wrong with this code? Assume the functions work correctly

   int LOTS = 10; 

   int amountOfFun {};

   while ( amountOfFun < LOTS ) { 

       amountOfFun = 0; 

       goToCamp(); 

       writeNeatCode(); 

       playGames(); 

       earnPoints(); 

       ++amountOfFun; 

       } 

    cout << "We've had a lot of fun! Time to go home" ;

Infinite Loop

300

What is wrong with this code according to Company's style guide? How would you fix it

int i;
i = f();

Initialization separate from declaration. Correct way int i = f();

400

What is the purpose of the auto keyword in C++?

The auto keyword in C++ is used to specify that the data type of a variable should be automatically deduced by the compiler at compile-time. This feature is called "type inference".

400

What is the difference between a static and a non-static member function in C++?

Static members are not destroyed when the control goes out of scope.

400

Which type of inheritance allows a derived class to inherit from multiple base classes.

Multiple inheritance

400

How many lines does this print?

char* s {“String”};
    for(const auto& c:s)
        cout << c << “\n”;

7

400

What is wrong with a variable name “tableName” used in a function

The names of variables (including function parameters) and data members are all lowercase, with underscores between words. Right name would be table_name. Additionally data members of a class should also end with an underscore like table_name_

500

What is the purpose of the const keyword in C++?

The const keyword in C++ is used to indicate that a variable's value cannot be modified after initialization.

500

Which member function in a class is invoked automatically whenever an object is going to be destroyed.

Destructor

500

Which C++ construct is used to define a generic function or class that can operate on different data types.

Template

500

What is the difference between the initialization of Y and Z?
constexpr int square(int x) {
    return x * x;
}

int main() {
    constexpr int y = square(5);
    int z = square(6);
    return 0;
}

y is evaluated at compile-time, z is evaluated at runtime

500

Constant Variables whose values never change during the duration of the program should be declared as const or constexpr and their name should start with a ___?

k
Example: kEpsilon = 1e-6;