Object-oriented programming (OOP)
centered around objects that include both data and functions that operate on them
| Term | Definition |
|---|---|
Object-oriented programming (OOP) | centered around objects that include both data and functions that operate on them |
T/F: ADT stands for Algorithmic Data Type | FALSE
--> ADT: abstract data type
--> specifies operations & behavior without specifying how data is stored/implemented
-->think of screen vs hidden parts |
ADT | -Specify values of data type
-Specify operations that data type can perform
-Hide details of how the data type is implemented |
T/F: A class declaration provides a pattern for creating objects, but doesn't make any objects | TRUE
--> ex) class MyClass { };
-->defines structure using keyword class |
An object typically hides its data, but allows outside code to access it through its ___ | public member functions
-->declared inside a class under public
-->accessible from part of program that has access to the object |
OOP: object's member variables are called ____, and its member functions are referred to as ____ | attributes, methods
-->attributes: variables / data members that store the state of an object; declared inside class
-->methods: functions that define the objects behavior; belong to a class, operate on attributes |
When three different objects of a class are created, they are said to be separate ____ of the class | instances |
When the body of a member function is defined inside a class declaration, its called _____ | inline |
T/F: A constructor is a public class function that is automatically invoked (called) whenever a class object is created | TRUE |
T/F: A class must have exactly one constructor | FALSE |
A constructor may have a return type of ____ | NONE: int, bool, void
*modified ? |
A constructor that doesn't require that any arguments be passed to it is called a ____ constructor | default |
A destructor is a member function that | is automatically called when an object is destroyed
-->wrong: causes program to end, can only be called by main function, removes old unneeded objects |
A ____ member function may be called by a statement in a function that is outside of the class | public |
A c++ member function that uses, but doesn't change, the value of a member variable is called ____ | an accessor |
Accessors are sometimes called ____ functions and mutators are sometimes called ____ functions | get, set |
If Circle is the name of a class, which of the following statements would create a Circle object named myCircle? | Circle myCircle;
*modified ? |
If setRadius is a Circle class function and myCircle is a Circle object, which statement would set myCircle's radius to 2.5? | myCircle.setRadius(2.5); |
T/F: A structure has member variables, like an object, but they are usually all public and accessed directly with the dot operator, instead of by calling member functions | TRUE |
Which statement creates an enumerated data type and defines an object of that type? ![]() | NONE |
T/F: ADT is a programmer defined data type that specifies the values the type can hold, the operations that can be performed, and how the operations are implemented | FALSE |
T/F: ADTs are normally implemented as classes | TRUE |
An object is a ____ of a class | instance |
T/F: A class declaration creates an object | FALSE |
The bundling of an object's data and functions together is called ____ | encapsulation
--> think back to visual of locked ball |
The ____ is used to protect important data | private access specifier |
Public members of a class object can be accessed from outside the class by using the | dot operator |
Member function that sets or changes the value stored in a member variable is called ____ | a mutator |
T/F: A private member function may only be called from a function that is a member of the same class | TRUE |
T/F: A constructor is a public class function that gets called whenever you want to re-intialize an object's member data | FALSE |
A constructor must have the same name as the | class |
The name of a destructor must begin with | a tilde (~) |
A class may have ____ default constructor(s) and ____ destructor(s) | only one, only one |
When a member function is defined outside of the class declaration, the function name must be qualified with the class name, followed by | the scope resolution operator (: :) |
If Square is the name of a class, which of the following statements would create a Square object named box? | Square box; |
If setSide is a Square class function and box is a Square object, which of the following statements would set the length of box's side to 5? | box.setSide(5); |
T/F: A class can have a member variable that is an instance of another class. This is called object nesting | FALSE |
A structure variable is similar to a class object in which of the following ways? ![]() | E |
When an object or structure variable is passed to a function as a constant reference ![]() | D |
What will the following code segment display? ![]() | 1 |



