Exam #2 Review Flashcards
(141 cards)
T/F: An Abstract data type (ADT) is a programmer-define data type that specifies the values the type can hold, the operations that can be performed on them, and how the operations will be implemented.
Fales
T/F: In C++ and other object-oriented programming languages, 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
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
A C++ 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-initialize 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 composition
True
A structure variable is similar to a class object in which way?
Its data can be initialized with a constructor, and it can be passed to a function or returned from a function, but not. It has member data that is usually private and accessed through public member functions
When an object or structure variable is passed to a function as a constant reference
- More efficient than passing by value
- Function cannot make any changes to the member variables
- Function accesses the original object, rather than a copy of it
What will the following code segment display?
enum Season {Spring, Summer, Fall, Winter} favoriteSeason;
favoriteSeason = Summer;
cout «_space;favoriteSeason;
1
Unlike regular variables, arrays can hold multiple….
values
T/F: The amount of memory used by an array depends solely on the number of elements the array can hold
False
To access an array element, use the array name and the element’s…
subscript
T/F: If a C++ program contains the following array definition
int score[10];
the following statement would store 100 in the first array element;
score[1]=100;
False