C++ 7-13 Midterm Review
A test using the isupper function will return false if the argument is an uppercase character.
False
Assume array1 and array2 are the names of two arrays. To assign the contents of array2 to array1, you would use the following statement: array1 = array2;
False
Before you can perform a bubble sort, the data must be stored in descending order.
False
Before you can perform a selection sort, the data must be stored in ascending order.
False
If you attempt to store data past an array's boundaries, it is guaranteed that the compiler will issue an error.
False
In-place member initialization no longer is available in C++11
False
The following string that uses a semicolon as a delimiter contains four tokens:"apple;cherry;lemon cream"
False
You must declare all data members of a class before you declare member functions.
False
What is the output of the following program? #include <iostream> using namespace std; class TestClass { public: TestClass(int x) { cout << x << endl; } TestClass() { cout << "Hello!" << endl; } }; int main() { TestClass test; return 0; }
Hello!
The destructor function's return type is
Nothing; destructors have no return type
The number of comparisons made by a binary search is expressed in powers of two.
True
Whereas object-oriented programming centers on the object, procedural programming centers on functions.
True
Select all that apply. Whitespace encompasses which of the following?
a tab, a newline, a space
The function that accepts a C-string containing a number as its argument and returns the integer equivalent is
atoi
The function that converts a C-string to an integer and returns the integer value is
atoi
The function that accepts a C-string as an argument and converts the string to a long integer is
atol
In a procedural program you typically have ________ stored in a collection of variables and a set of ________ that perform operations on the data.
data, functions
Objects are created from abstract data types that encapsulate ________ and ________ together. Question 69 options:
data, functions
When a constructor function accepts no arguments, or does NOT have to accept arguments because of default arguments, it is called a(n)
default constructor
Members of a class object are accessed with the
dot operator
The individual values contained in an array are known as
elements
The C-string company[12] can hold
eleven characters and the null terminator
Although two-dimensional arrays are a novel idea, there is no known way to pass one to a function.
false
Which of the following will return true if the argument is a printable character other than a digit, letter, or space?
isprint
Assume that myCar is an instance of the Car class and that the Car class has a member function named accelerate. Which of the following is a valid call to theaccelerate member function?
myCar.accelerate();
The ________ is automatically appended to a character array when it is initialized with a string constant.
null terminator
How many default constructors can a class have?
only one
This vector function removes an item from a vector.
pop_back
This vector function is used to insert an item into a vector.
push_back
A ________ algorithm is a method of locating a specific item of information in a larger collection of data.
search
The following is the pseudocode for which type of algorithm? For start = each array subscript, from the first to the next-to-last minIndex = start minValue = array[start] For index = start + 1 to size - 1 if array[index] < minValue minValue = array[index] minIndex = index end if end For swap array[minIndex] with array[start] end For
selection sort
An array of string objects that will hold five names would be declared with which of the following statements?
string names[5];
The function that accepts a pointer to a C-string as an argument and returns the length of the C-string, not including the null terminator is
strlen
The function that reverses the order of a C-string is
strrev
A library function that can find one C-string inside another is
strstr
Objects in an array are accessed with ________, just like any other data type in an array.
subscripts
What will the following C++11 code display? vector<int> numbers{ 3 , 5 }; for (int val : numbers) cout << val << endl;
3 5
What is the last legal subscript that can be used with the following array?int values[5];
4
An individual array element can be processed like any other type of C++ variable.
True
If an array is partially initialized, the uninitialized elements will be set to zero.
True
If you do not declare a destructor function, the compiler will furnish one automatically.
True
The following is the pseudocode for which type of algorithm? Set first to 0....
binary search
The expression being tested by the statement shown below will evaluate to true if var1 is ________. if (!isdigit(var1))
both an alphabetic character and a symbol such as $ or &
Which of the following defines an array of C-strings that will hold 49 characters and the null terminator?
char str[50];
The process of object-oriented analysis can be viewed as the following steps:
identify objects, then define each object's attributes, behaviors, and relationships
An array with no elements is
illegal in C++
Where are class declarations usually stored?
in their own header files
The ________ sort usually performs fewer exchanges than the ________ sort.
selection, bubble
The advantage of a linear search is its
simplicity
This vector function returns the number of elements in a vector
size
Array elements must ________ before a binary search can be performed.
sorted
Algorithms used to arrange random data in some order are ________ algorithms.
sorting
In C++11, assuming mychar is a char variable and mystring is a string, what is the value of mychar after the following statement executes?mychar = mystring.front();
the first character of mystring
An element of a two-dimensional array is referred to by
the row subscript of the element followed by the column subscript of the element
What is the result after the following statement executes?char var1 = tolower('A');
var1 stores the ASCII value for lowercase 'a'