C++ Chapters 7, 9, 10 Review
If you were writing the definitions for the Canine class member functions and wanted to place these in their own file, what should you name the file?
"canine.cpp"
If you were writing a class declaration for a class named Canine and wanted to place it in its own file, what should you name the file?
"canine.h"
To determine that an item is not in an unordered array of 100 items, linear search would examine an average of ________ values.
100
If a selection sort is used to arrange the numbers 8 6 4 9 3 7 in ascending order, what order will the data be in after the first pass of the sort is completed?
3 6 4 9 8 7
If a bubble sort is used to arrange the numbers 7 5 3 9 2 6 in ascending order,what order will the data be in after the first pass?
5 3 7 2 6 9
To determine that a value is not present in an unordered array of 50 items, linear search must examine an average of _________ values.
50
To locate a value that is in an ordered array of 50 items, linear search must examine at most ________ values.
50
If a binary search is used to search for the number 4 in the 11-element array shown below, which value will the 4 be compared to first? 1 2 3 4 6 7 8 9 10 12 17
7
What does ADT stand for?
Abstract Data Type
If Circle is the name of a class, which of the following statements would create a Circle object named myCircle?
Circle myCircle;
True or false: C++ class objects are always passed to functions by reference.
False
True/False: A class declaration provides a pattern for creating objects, so when a class is declared it automatically creates an object.
False
True/False: A constructor is a public class function that gets called whenever you want to re-initialize an object's member data.
False
True/False: An ADT is a programmer-defined 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.
False
True/False: If employee is an instance of a class with 3 member variables (name, salary, and department), the values of all three members will be output by the statement cout << employee;
False
True/False: Using a linear search, you are more likely to find an item than if you use a binary search.
False
_____________________ programming is centered around objects.
Object-oriented
______________________ programming is centered around functions or procedures.
Procedural
What are the two common programming methods in practice today?
Procedural programming and object-oriented programming
True/False: A binary search requires that the elements be in order.
True
True/False: Any sorting algorithm, such as bubble sort or selection sort, that can be used to sort an array can also be used to sort a vector.
True
What two things must a programmer know about an ADT to use it?
What values it can hold, what operations it can perform
A public member can be accessed by _________________.
a functions outside the class
A C++ member function that sets or changes the value stored in a member variable is called ____________.
a mutator.
A class member function that uses, but does not change, the value of a member variable is called a(n) _______.
accessor function
In OOP terminology, an object's member variables are often called its _________, and its member functions are sometimes referred to as its ___________.
attributes; methods
The _________ sort usually performs more exchanges than the _________ sort.
bubble sort; selection sort
A constructor must have the same name as the ____________.
class
A class constructor is a member function with the same name as the _____.
class name
A class may only have one default ____ and one _____.
constructor, destructor
A constructor is automatically called when an object is _______.
created
An object is a software entity that combines both ___________ and __________ in a single unit.
data, procedures
Before a structure variable can be created, the structure must be
declared
A constructor whose parameters all have default values is a(n) ___ constructor.
default
A(n) ____ constructor is one that requires no arguments.
default
A destructor is a member function that is automatically called when an object is __________.
destroyed
The _____ operator is used to access structure members.
dot
Bundling together an object's data and procedures is called ____________.
encapsulation
When a structure variable is created its members can be initialized with either a(n) __________ or a(n ) ___________.
initialization list, constructor
When a member function's body is written inside a class declaration, the function is a(n) ____ function.
inline
In general, it is considered good practice to have member functions avoid doing _____
input and output operations
An object is a(n) ___________ of a class.
instance
Creating a class object is often called ____________ of a class.
instantiation
In an ADT, the implementation details are _________ the interface through which a program uses it.
kept separate from
A _________ search uses a loop to sequentially step through an array.
linear search
The _________ search is adequate for searching through small arrays, but not through large ones.
linear search
Once a class is declared, how many objects can be created from it?
many
A structure is like a class but normally only contains member variables and no
member functions
Normally a class's ______________ are declared to be public.
member functions
An object's data items are stored in its _________________.
member variables
Normally a class's ______________ are declared to be private.
member variables
The procedures or functions an object performs are called its __________.
methods
A binary search begins by examining the ________ element of an array.
middle
A class member function that changes the value of a member variable is called a(n) ______.
mutator function
If setRadius is a Circle class function and myCircle is a Circle object, which of the following statements would set myCircle's radius to 2.5?
myCircle.setRadius(2.5);
A class can have a member variable that is an instance of another class. This is called:
object composition
A private member can be accessed by _______________ _
only member functions of the same class
A class may have ________ default constructor(s) and ________ destructor(s).
only one; only one
A class may have more than one constructor, as long as each has different ____________.
parameters
When a member function performs a task internal to the class and should not be called by a client program, the function should be made ________.
private
By default , are the members of a structure public or private?
public
When a member function forms part of the interface through which a client program can use the class, the function must be ________.
public
Constructors cannot have a(n) ____ type.
return
When searching for a particular object in an array of objects, it is necessary to compare the __________ to the value in each examined object's ____________.
search key; key field
When sorting an array of objects, if the values in the data member being sorted on are out of order for two objects, it's necessary to ____________.
swap the entire two objects.
It is considered good programming practice to store the declaration for a class, its function definitions, and the client program that uses the class in ______ files.
three separate
A destructor has the same name as the class but is preceded by a ______ character.
tilde(~)