Definitions
Implications
Modifications
Interfaces
MISC
100

How do you initialize a new class? 

class name_of_the_class {


}; 
100

Where must you write the following: 

Point Point_1; 

The Main() function. 

100

What is the only type that can be used to modify the data members?

void. 

100

What are the 2 interface types. 

Public: and Private: 

100

What does OOP stand for? 

Object Oriented Programming. 

200

How do you call a class in the main function? 

Name_Of_The_Class Variable_Name; 

200

What is usually the function of a type void function? 

To print something or set something. 

200

What all can access the data members inside of the private: section? 

Constructors and Member Functions ONLY

200
Inside which interface type does the member functions go and why? 

Public: because we want to be able to access it else where in the script? 

200

What are examples of OOP in C++ that we already learned about. Give examples. 

Strings and Cin & Cout.

300

What is used to initialize a constructor (String, Int, Double, etc)? 

You DO NOT add anything when you initialize a constructor? 

300

List 3 differences between the getters and setters? 

- Getters are any type that's not void. 

- Getters can return. 

- Getters cannot edit any data members in the private:. 

- Setters can only be type void. 

- Setters can edit values. 

- Setters can print. 

300

Spot the error: Assume all the other code segments have been added and are correct! 

string Eat::munch(string item) {

eating = item; 

}

There is no error! How many of you spent the whole time searching for the error? 

300

Where all can the public: be accessed inside a script? What is another name we give to similar things? 

Anywhere in the script. Global. 

300

Name one other very famous coding language that uses OOP.

Java, Javascript, Python, Ruby, Swift, etc. 

400

Spot the error(s)! 

Class Cat {

public: 

string meow(); 

private:

}; 

...

void Cat::meow() {

cout << "meow" << "\n"; 

return "meow"; 

- C in class is capitalized.

- function is initialized as type string but is referred to as type void. 

- attempted to use "cout" inside a function of type string. 

- cannot use return inside a function of type string. 

400

You want to run a basic store and want to make an app for it. You have 18 different data members, atleast how many different member functions must you have, not including any extra ones you might have? (None of the data members are const;) 

18 x 2 = 36. One getter and one setter for each data member. Technically any whole number less than 36 and greater than 1 would work, but it would not be very practical.

400

A discord mod wants to add a table of everyone in their server. Make a data member to address this issue. (Hint: they're thinking of banning some people). 

...

private:

vector<string> members = {}; 

}; 

400

You and your best bud begin to code. You split up to compare results later to combine them to make something better! Here's what you both made in 5 minutes! Your friend calls you stupid! How could he, so you call him back. Are there really any errors? If so what are they? 

// You: 

Class part  {

Public: 

int set_size(int new_size); 

void get_size(); 

Private: 

int size;

}; 

// Buddy: 

Class part  {

public: 

Void set_size(int new_size); 

string get_size(); 

private: 

int size;

}; 

You

- "C" in class is uppercase. 

- "P" in public is uppercase. 

- "P" in private is uppercase. 

- Setter is set given type int. 

- Getter is given type void. 

Buddy: 

- "C" is class is uppercase. 

- "V" in void is uppercase. 

- get_size is supposed to return type int yet is initialized as type string. 

400
How does the term "encapsulation" relate to OOP? 
An object allows the programmer to call and use the member functions without knowing how the code was actually written, masking the true complexity of the code. This is encapsulation, it hides the complex parts without hindering function. 
500

You made a wonderful program for the OOP lab and asked your best friend to check it for you. He says you made a mistake, but you tell him that he's dumb and he doesn't pay attention in class. He tells you that no, you're dumb and explains why. He says you added code inside the {} of a function inside the class. He says this will not run, but you say it will. Who's right? You or your friend? 

You're correct! Even though it is not advised you add code inside the {} of a function inside a class, it will however still run without any errors (for our purposes).
500

What's the error? -- Pretend the class has already been defined. There are 3 data members, 8 member functions and one constructor. 

Void Money::Money(Double change) {

total += change; 

debt -= change; 

}

- V in void is capitalized. 

- D in double is capitalized.  

- all 3 data members are not used in the constructor. 

500

void count(int add_amnt) {

if (add_amnt >= 1000) { // Tax slabs starts at 1000. 

amnt += add_amnt*(1?); // Must only add 95% of the amount. 5% tax. 

tax = add_amnt*(2?);

}

else {

amnt += add_amnt; 

tax = 3?; 

}

}

1? 0.95

2? 0.05

3? 0.00

500

Under which can there be calls to const. public: or private: ?

Both! You can have member functions with const and also data members with type const. 

500

When did C++ become an OOPL? If you can't answer you do not loose points, you can only gain. 

1997. 

M
e
n
u