Module 2: Chapter Quizzes
44 flashcards · Programming Languages · by Gabriella Torres
A C++ member function that sets or changes the value stored in a member variable is called
a mutator.
An object typically hides its data but allows outside code to access it through its
public member functions.
A constructor may have a return type of
None of the above (none of these: void, int, bool)
A structure variable is similar to a class object in which of the following ways?
B and C, but not A
A constructor that does not require that any arguments be passed to it is called a(n) ________ constructor.
default
Accessors are sometimes called ________ functions and mutators are sometimes called ________ functions.
get, set
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 );
The bundling of an object's data and functions together is called
encapsulation.
A constructor must have the same name as the
class.
The ________ is used to protect important data.
private access specifier
When three different objects of a class are created, they are said to be separate ________ of the class.
instances
In OOP terminology, an object's member variables are often called its ________, and its member functions are sometimes referred to as its ________.
attributes, methods
A class may have ________ default constructor(s) and ________ destructor.
only one, only one
A C++ member function that uses, but does not change, the value of a member variable is called
an accessor.
When the body of a member function is defined inside a class declaration, it is called a(n) ________ function.
inline
A(n) ________ member function may be called by a statement in a function that is outside of the class.
public
A destructor is a member function that
is automatically called when an object is destroyed.
The name of a destructor must begin with
a tilde (~)
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 Circle is the name of a class, which of the following statements would create a Circle object names myCircle?
Circle myCircle;
If the scores array is defined like this: int scores [ ] = {4, 7, 4, 8, 9}; What will the following statement display? cout << scores[4];
9
The elements of an array can be
Any of the above a. objects b. structures c. strings d. Any of the above e. None of the above
Unlike regular variables, arrays can hold multiple __________
values
Which of the following statements will correctly carry out the operation stated in the comment to its right?
None of the above a. array2 = 5; // Place a 5 in each element of array2. b. array 2 = array1 // Copy the elements of array 1 into array 2 c. cout << array2 // Output the elements stored in array 2 d. None of the above e. A and B, but not C
To access an array element, use the array name and the element's __________
subscript
A two-dimensional array can be viewed as
a table with rows and columns
To step through a one-dimensional array, accessing the elements one by one, it would be most appropriate to use __________ loop.
a for loop
The following two arrays string deptName[3] = {"Manufacturing", "Sales", "Business Office"); double deptBudget[3] = {200000.0, 60000.0, 50000.0}; are an example of __________ arrays.
parallel
An array can store multiple values, but the values must be __________.
all the same data types
By using the same _________ you can build relationships between data stored in two or more arrays.
subscript
The statement int grades[ ] = {100, 90, 99, 80}; is an example of __________
implicit array sizing.
The following statement for (int val : myArray) cout << val << " "; is an example of a(n) __________
ranged-base for loop.
To add up all the values in a two-dimensional array it would be best to use __________.
a nested for loop
Subscript numbering in C++ __________.
automatically begins with zero
When an array is passed to a function, it is actually __________ the array that is passed.
the starting memory address of
A sorting algorithm can be used to arrange a set of __________ in __________ order.
All of the above a. strings, ascending b. numeric values, descending c. numeric values, ascending d. strings, descending e. All of the above
A(n) __________ search is more efficient than a __________ search.
binary, linear
A binary search begins by examining the __________ element of an array.
middle
To determine that an item is not in an unordered array of 100 items, how many values must linear search examine on average?
100
The advantage of a linear search is that
Both A and D a. it is simple b. it is fast c. it is efficient d. it can be used on unordered data. e. Both A and D
We can measure the complexity of an algorithm that solves a computational problem by determining the number of __________ for an input of size n.
basic steps it requires
A search can be performed on an array of
All of the above, whether the data is in order or not a. strings b. integers c. objects d. All of the above, but only if the data is in order e. All of the above, whether the data is in order or not
The __________ sort usually performs fewer exchanges than the __________ sort.
selection, bubble
The linear search is adequate for searching through __________ arrays, but not through __________ ones.
small, large