Final Study Guide, Quiz 2
[C++11]: Which of the following statements is false?
C++11 added the keyword using as another mechanism for creating type aliases. The following declaration is equivalent to the typedef in second choice above: using Card* = CardPtr;
The operators that cannot be overloaded are _________, __________, ___________ and ___________.
., ?:, .*, and ::
A header file is typically given the filename extension:
.h
The only integer that can be assigned directly to a pointer is _________.
0
memcmp would return ___________ for the call memcmp("Hi, how are you?", "Hi, how are things?", 6).
0
Assume that the function call operator() is overloaded for data type String in the usual sense of selecting a substring from a larger string. For a String object string1 with the character string "ABCDEFGHI", what string does string1(4, 2) return?
"EF"
If string s contains "antidisestablishmentarianism", then s.substr(7, 13) would be:
"establishment"
Which of the following preprocessor directives does not constitute part of the preprocessor wrapper?
#include
Assuming that GradeBook.h is found in the current directory and the iostream header file is found in the C++ Standard Library header file directory, which of the following preprocessor directives will fail to find its desired header file?
#include <GradeBook.h>
Any file that uses a class can include the class's header via a(n) ____________ preprocessing directive.
#include.
Which of the following is not a bitwise operator?
*
Iterators are similar to pointers because of the:
* and ++ operators.
Three of the following expressions have the same value. Which of the following expressions has a value different from the others'?
*ptr
Inside a function definition for a member function of an object with data member x, which of the following is not equivalent to this->x:
*this.x
Which of the following is not overloaded for strings?
-=
Function mismatch returns:
A pair containing two iterators pointing to the two locations in the specified sequences that do not match.
catch blocks are not required to contain:
A parameter name.
Which of the following statement is false?
A pointer-based string is a string object.
All of the following are true of an ostringstream object except that:
A stream insertion operation cannot be used to append additional data to it.
Which of the following is false?
A string can be defined to store any data type.
Which of the following is not true of class template vector?
A vector can store only data of type int.
For an ifstream object A, a class type B and a local variable of type B called C, the proper way to read in one B object from A into C is:
A.read(reinterpret_cast<char*>(&C), sizeof(B));
A Standard Library algorithm cannot:
Access Standard Library members directly.
__________ is not allowed.
Accessing individual bits in a multi-bit bit field.
Structure variable declarations can be incorporated into a structure definition by placing a comma-separated list of variable names:
After the right brace and before the semicolon.
Select the false statement regarding exceptions.
All exception classes are accessible via <exception>.
Exception handling may allow a program to:
All of the above
Which of the following is not a category of the Standard Library algorithms?
All of the above are categories of the Standard Library Algorithms.
Which of the following is not one of the disadvantages of using the "copy-and-paste" approach to duplicating code from one class into another class?
All of the above are disadvantages of the "copy-and-paste" approach.
Which of the following is not true of a class that will be used to instantiate function objects?
All of the above are true about a class that will be used to instantiate function objects.
Which of the following does not have a stream associated with it?
All of the above have streams associated with them.
[C++14] : Which of the following statements is false?
All of the above statements are true.
Class deque provides:
All of the above.
Random access files are more effective than sequential files for:
All of the above.
string iterators:
All of the above.
Returning references to non-const, private data:
Allows private member variables to be modified, thus "breaking encapsulation."
[C++14]: Which of the following statements is false?
Always use C++11's versions of equal and mismatch - these are preferred because they compare the lengths of the ranges for you, eliminating a potential source of logic errors.
The type of function a client would use to check the balance of a bank account would be:
An access function.
How many times will the following loop print hello? i = 1; while (i <= 10) { cout << "hello"; }
An infinite number of times.
An error occurs if:
An object data member is not initialized in the member initialization list and does not have a default constructor.
Run-time type information can be used to determine:
An object's type.
Using a while loop's counter-control variable in a calculation after the loop ends often causes a common logic error called:
An off-by-one error.
Abstract classes:
Are defined, but the programmer never intends to instantiate any objects from them.
What is the name of the values the method call passes to the method for the parameters?
Arguments.
Which of the following is not a dynamic data structure?
Array
Exception handling should not be used:
As an alternative for program control.
Default type parameters are allowed only:
As the rightmost (trailing) parameters in a template's type-parameter list.
Which of the following assignments would be a compilation error?
Assigning the address of a base-class object to a derived-class pointer.
If pairs is a map containing int keys and double associated values, the expression pairs[5] = 10:
Associates the value 10.0 to the key 5 in pairs.
The list sequence container does not:
Automatically sort inserted items.
When an object of a derived class is instantiated, the __________ constructor initializes the _________ members.
Base class, base class.
The line: virtual double functionX() const = 0; in a class definition indicates that the class is probably a:
Base class.
Which of the following statement is true?
Base-class constructors are not automatically inherited by derived classes.
Which of the following statements about searching algorithms and their efficiency is false?
Big O notation is one way to describe how likely it is that a searching algorithm will find its target.
For operators overloaded as non-static member functions:
Binary operators can have one argument, and unary operators cannot have any.
Let Bit1 = Bit2 = 1. Which of the following does not have the same result as the others?
Bit1 ^ Bit2
A default constructor:
Both first and second choice.
To execute multiple statements when an if statement's condition is true, enclose those statements in a pair of:
Braces, { }.
Which of the following is false?
C++ ensures that you cannot "walk off" either end of an array.
Which is the proper way to create a built-in array of structure variables of type Data?
Data MyArray[10];
Attributes of a class are also known as:
Data members.
Pseudocode normally does not include:
Declarations.
[C++11]: To prevent class objects from being copied or assigned, you can:
Declare as private the class's copy constructor and overloaded assignment operator or declare the class's copy constructor and overloaded assignment operator with with = delete after the parameter list.
Which of the following statements will not produce a syntax error?
Declaring an object to be const.
__________ is not an advantage of linked lists when compared to arrays.
Direct access to any list element.
The algorithms in the Standard Library:
Do not depend on the implementation details of the containers on which they operate.
Which of the following statements is false?
Functions rbegin and rend return iterators that can be used to modify data, and rcbegin and rcend return const iterators that cannot be used to modify data.
Which of the following statements is false?
Global Positioning System (GPS) devices a single satellite to retrieve location-based information.
static data members of a certain class:
Have class scope.
Select the false statement. Container adapters:
Have limited iterator support.
Iterators do not:
Have range checking.
The strtol and stroul functions do not:
Have the same return types.
The C++ compiler makes objects take up more space in memory if they:
Have virtual functions.
The choice of which sorting algorithm to use does not affect:
How sorted the vector will be
The main difference between set and multiset is:
How they handle duplicate keys.
Which of the following statement is true?
If a base class declares a pure virtual function, a derived class must implement that function to become a concrete class.
A merge sort operation runs in:
O(n log n) time.
Selection sort has a Big O of:
O(n^2)
Which of the following represents the efficiency of the insertion sort?
O(n^2)
Which of the following is not allowed?
Objects of abstract classes
Which of the following statement is true?
One of the most common uses of a deque is to maintain a first-in, first-out queue of elements. In fact, a deque is the default underlying implementation for the queue adaptor.
For a class template, the scope resolution operator (::) is needed:
Only in the definitions of the member functions defined outside the class.
A copy constructor must receive its argument by reference because:
Otherwise infinite recursion occurs.
Arrays are:
Passed by reference unless inside a structure.
In the source-code file containing a class's member function definitions, each member function definition must be tied to the class definition by preceding the member function name with the class name and ::, which is known as the:
Scope resolution operator.
Which of the following is not an Standard Library container type?
Second-class containers.
All programs can be written in terms of three types of control statements: _____________, ___________ and ___________.
Sequence, selection, iteration
The prototypes of overloaded cast operator functions do not:
Specify a return type.
The capabilities of inputting and outputting strings in memory are known as:
String stream processing.
Assuming that string1 = "hello" and string2 = "hello world", which of the following returns 0?
Strncmp(string1, string2, 5);.
The for_each function applies a general function to each element in the specified range. This general function should:
Take an argument of the elements' type and return nothing.
Functions iter_swap and swap_ranges are similar in that both:
Take forward iterators as arguments.
The array subscript operator [], when overloaded, cannot:
Take multiple values inside (e.g., [4,8]).
An exception:
Terminates the block where the exception occurred.
The main difference between a pure virtual function and a virtual function is:
That a pure virtual function cannot have an implementation.
Which of the following statement is true?
The ++ operation on an iterator moves it to the container's next element.
In the UML, the top compartment of the rectangle modeling a class contains:
The class's name.
Which of the following statement is false?
The container member function cbegin returns an iterator that refers to the container's first element.
Calling a member function of an object requires which item?
The dot operator.
If a program attempts to insert a duplicate key into a set:
The duplicate key will be ignored.
Which of the following is not an argument of the assign member function?
The end location.
If v1 is a vector<int> containing some number of int elements sorted in ascending order, after these statements execute: std::vector<int> results1; std::vector<int> results2; std::unique_copy(v1.begin(), v1.end(), std::back_inserter(results1)); std::reverse_copy(v1.begin(), v1.end(), std::back_inserter(results2)); which of the following could be true?
The first element in results1 matches the last element in results2.
Which of the following statements is true?
The ostream member function write can write to standard-output stream cout.
In a typical nested for loop (not a range-based for loop) used to process a two-dimensional array, following the end of each execution of the inner for loop:
The outer for loop increments its counter variable.
hat will be the output after the following C++ statements have been executed? int a{4}; int b{12}; int c{37}; int d{51}; if (a < b) { cout << "a < b" << endl; } if (a > b) { cout << "a > b" << endl; } if (d <= c) { cout << "d <= c" << endl; } if (c != d) { cout << "c != d" << endl; }
a < b c != d
The sequence containers and ____________ containers are collectively referred to as the firstclass containers.
associative
Which of the following provides bounds checking?
at
Which of the following is most likely a base class of the other three?
automobile.
A lambda function can capture local variables ________ and manipulate them inside the lambda's body.
by value or by reference.
Which of the following will not increment c by 1?
c + 1;
When an object of a derived class is instantiated, the base class's _____________ is called implicitly or explicitly to do any necessary initialization of the base-class data members in the derived-class object.
constructor
The three key components of the "STL" portion of the Standard Library are _________, ________ and __________.
containers, iterators and algorithms
A(n) _________ constructor initializes the container to be a copy of an existing container of the same type.
copy
Which of the following is not a mathematical algorithm included in the Standard Library?
copy
Assuming that all four of the following functions are defined, which one will be called by the function call square( 23.4 )?
double square( double num )
Operator _________ can be used to downcast base-class pointers safely.
dynamic_cast
A nonmember function must be declared by the class as a(n) ___________ of a class to have access to that class's private data members.
friend.
Which file open mode would be used to write data only at the end of an existing file?
ios::app
In a(n) ___________ relationship, an object of a derived class also can be treated as an object of its base class.
is-a or inheritance (for public inheritance)
Which of the following is not true about files?
istream, ostream and iostream are derived from ifstream, ofstream and fstream, respectively.
Standard Library algorithms operate on container elements indirectly, using __________.
iterators
The __________ and ___________ operators are used to shift the bits of a value to the left or to the right, respectively.
left-shift operator (<<), right-shift operator (>>)
The pointer to the next node in a linked list is referred to as a(n) ____________.
link
The three types of languages discussed in chapter 1 are ______________, __________________and ____________.
machine languages, assembly languages, high-level languages.
Every C++ program begins execution at the function _________ .
main.
The bitwise AND operator & is often used to ____________ bits (i.e., to select certain bits from a bit string while zeroing others).
mask
The ___________ function allows characters of one part of a string to be copied into another, overlapping part of the same string.
memmove
To change the string "ABCDEFGHI" to "aaaaaFGHI" you would use the _________ function.
memset
Which of the following is not a member function of all sequence containers?
middle
The C++11 ___________ algorithm locates both the smallest and largest elements in a range.
minmax_element
C++ provides for ___________ , which allows a derived class to inherit from many base classes, even if the base classes are unrelated.
multiple inheritance
Which of the following is not a valid C++ identifier?
my Value
Which of the following best describes the array name n in the declaration int n[10];?
n is a constant pointer to nonconstant data.
The operator ______ is used to dynamically allocate memory and construct an object; this operator returns a pointer to the object.
new
The operator ________ dynamically allocates memory for an object of a specified type and returns a(n) ________ to that type.
new, pointer
A member function should be static if it does not access ____________ class members.
non-static.
Pointers may be assigned which of the following values?
nullptr.
Member function _________ of the file streams fstream, ifstream and ofstream opens a file.
open
[C++11]:Which of the following is not a keyword that was added to C++ in the new C++11 standard?
operator
Suppose a and b are integer variables and we form the sum a + b. Now suppose c and d are floating-point variables and we form the sum c + d. The two + operators here are clearly being used for different purposes. This is an example of __________________.
operator overloading
Function objects have their functions called by using:
operator()
The correct function name for overloading the addition (+) operator is:
operator+
A back_inserter calls the container's default _______ function to insert an element at the end of the container. If an element is inserted into a container that has no more space available, the container grows in size.
push_back
Which of the following is not a member function of all sequence containers?
push_front
Which of the following C++ statement is calculating the remainder after q is divided by divisor and assign the result to q?
q %= divisor;
What is wrong with the following while loop? while (sum <= 1000) { sum = sum - 30; }
sum = sum - 30 should be sum = sum + 30 or else the loop may never end.
Class string has member function __________ to interchange the data stored in two string objects
swap
Which of the following functions would not be used to write data randomly to a random access file?
tellg
Which of the following bitset member functions cannot be called with an empty argument list?
test
A(n) ___________ is a nonlinear, two-dimensional data structure that contains nodes with two or more links.
tree
The correct order in which an exception is detected and handled is:
try, throw, catch
Keyword _______________ is used to create a synonym for a previously defined data type.
typedef
The __________ operator returns a reference to a __________ object:
typeid, type_info
If dynamic memory has been allocated for an object and an exception occurs, then:
A memory leak could result.
The functions of the character-handling library typically manipulate characters as:
ints
At most, how many comparisons are required to search a sorted vector of 1023 elements using the binary search algorithm?
10
What is the output of the following statement? cout << strspn("Cows like to moo.", "Ceik losw");
10.
Evaluate (00001000 & 11000101) ^ (11110000).
11110000
An algorithm that requires __________ operations to complete its task on n data elements is said to have linear runtime.
2 n + 1
If string s1 is lexicographically greater than string s2, then the value returned by s2.compare(0, s2.size(), s1) must be?
A negative number.
A queue performs the following commands (in pseudo-code): enqueue 4, 6, 8, 3, 1 dequeue three elements enqueue 3, 1, 5, 6 dequeue two elements What number is now at the front of the queue?
3
What is the final value of x after performing the following operations? int x{21}; double y{6}; double z{14}; y = x / z; x = 5.5 * y;
8.
When a member function is defined outside the class definition, the function header must include the class name and the ________________, followed by the function name to "tie" the member function to the class definition.
:: scope resolution operator
In order to perform file processing in C++, which header files must be included?
<iostream> and <fstream>.
Header ________ must be included for class string.
<string>
Which of the following is not an arithmetic operator?
=
Which of the following operators can be overloaded as a non-member function?
==
Which of the following statements about friend functions and friend classes is false?
A class can either grant friendship to or take friendship from another class using the friend keyword.
The number of bits in a bit field is specified with:
A colon as in bitfield : 4
A constructor can specify the return type:
A constructor cannot specify a return type.
Select the false statement. Depending on the compiler:
A failed new operation can automatically be caught at compile time.
static member functions:
Can access only other static member functions and static data members.
The delete [] operator:
Can delete an entire array of objects declared using new.
strings:
Can use the subscript operator to access individual characters.
The total number of elements that can be stored in a string without increasing its current amount of allocated memory is called its:
Capacity
Select the false statement. The reinterpret_cast operator:
Changes the value of the object to which its operand points.
If the line: friend class A; appears in class B, and the line: friend class B; appears in class C, then:
Class A can access private variables of class B.
The first step performed by the binary search algorithm at each iteration is to:
Compare the search key with the middle element in the current subvector.
The ___________ creates object code and stores it on disk.
Compiler.
strtok does not:
Completely tokenize the string the first time it is called.
Nontype parameters are:
Constants.
typedef is used to:
Create a type name that is an alias for another type name.
The expression std::multimap<int, double, std::less<int>>::value_type(15, 2.7):
Creates a pair object in which first is 15 (type int) and second is 2.7 (type double).
[C++11]: Which of the following statements is false?
Each C++11 function that converts a string to an integral type receives two parameters—a string containing the characters to convert and a pointer to a size_t variable where the function stores the index of the first character that was not converted (a null pointer, by default).
Which of the following statements about C++11's functions for converting string objects to numeric values is false?
Each function attempts to convert its entire string argument to a numeric value.
Which of the following statements is true of a priority_queue?
Each of its common operations is implemented as an inline function.
The try block cannot:
Enclose its own catch blocks.
The function call string1.erase(5) will:
Erase all characters starting from and including the character in position 5 to the end of string1.
Which of the following is not a key organization in the open-source community?
Firefox
[C++11]: Which of the following is false?
First and third choice.
Select the false statement. If an exception is thrown from a constructor:
For an array, destructors for all array elements are called, even if those array elements have not yet been constructed.
Which of the following languages is used primarily for scientific and engineering applications?
Fortran.
[C++11]: Which of the following statements about inheriting base class constructors is false?
If an inherited base-class constructor has default arguments, the line of code in Part (a) causes the compiler to generate a derived-class constructor with the same default arguments.
[C++11]: Which of the following is true?
If you define any constructors with arguments, the compiler will not define a default constructor.
[C++11]: Which of the following statements is true?
In C++11, only classes that are not declared as final can be used as base classes.
Which of the following statements about nested if...else statements is true?
In an if body, an inner if...else executes only if the outer if statement's condition is true.
Which of the following statements about pointer initialization and values is false?
In the new standard, you should use the constant null_ptr to initialize a pointer instead of 0 or NULL.
Which of the following statements is false?
In use today are more than a trillion general-purpose computers and trillions more cellphones, smartphones and other handheld devices.
The advantages of using typedef do not include:
Increasing the efficiency of accessing struct member variables.
Which of the following statements is false?
Information in the memory unit is persistent—it is retained when the computer's power is turned off.
Which of the following is the correct hierarchy of iterator categories (weakest at the left)?
Input/output, forward, bidirectional, random access.
The order of the arguments passed to function replace_copy_if must be:
InputIterator, InputIterator, OutputIterator, PredicateFunction, ReplacementValue.
In general, linked lists allow:
Insertions and removals anywhere.
Assuming the following is the beginning of the constructor definition for class BasePlus-CommissionEmployee which inherits from class Point: BasePlusCommissionEmployee::BasePlusCommissionEmployee(string first, string last, string ssn, double sales, double rate, double salary) : CommissionEmployee(first, last, ssn, sales, rate) The line beginning with a colon(:)
Invokes the CommissionEmployee constructor with arguments.
A string array:
Is actually an array of pointers.
Unlike a vector, a deque:
Is not stored in contiguous memory.
The conditional operator (?:):
Is the only ternary operator in C++.
Which of the following is false about a function to which a built-in array is being passed?
It always knows the size of the built-in array that is being passed.
Which of the following is true of pseudocode?
It helps the programmer "think out" a program.
Which of the following is not true of a destructor?
It releases the object's memory.
Which of the following statement is false?
Keywords typename and class as used with a template type parameter specifically mean "any user-defined class type."
When a client code programmer uses a class whose implementation is in a separate file from its interface, that implementation code is merged with the client's code during the:
Linking phase.
An array is not:
Made up of different data types.
Downcasting enables:
Making a base-class pointer into a derived-class pointer.
Class templates:
Must put template< typename Type > before the class definition.
An explicit constructor:
Must take exactly one argument.
Having a loop within a loop is known as:
Nesting.
Which of the following is not a key component of the Standard Library?
Pointers.
A client changing the values of private data members is:
Possible using public functions and references.
Which of the following operations has the highest precedence?
Postincrement.
Which of the following is not a good example of a hierarchy likely to be modeled by inheritance?
Prime numbers.
Which of the following is not one of the six logical units of a computer?
Printer.
Concrete classes that inherit virtual functions but do not override their implementations:
Receive pointers to their base classes' virtual functions.
Pointers cannot be used to:
Reference values directly.
Member function definitions:
Require the scope resolution operator only when being defined outside of the definition of their class.
Two structure variables of the same type with the same member values, when compared will:
Result in a compile error.
Functions lower_bound, upper_bound and equal_range are different in their:
Return types.
sizeof:
Returns the total number of bytes in a variable.
Let x be an unsigned int on a machine with 4-byte unsigned ints. What effect does x>>=1; x<<=1; have?
The rightmost bit of x is set to 0.
The arguments passed to replace do not include:
The subscript of the element where the replace operation ends.
The main difference between the functions atof, atoi and atol is:
Their return types.
What mistake prevents the following class declaration from functioning properly as an abstract class? class Shape { public: virtual double print() const; double area() const {return base * height;} private: double base; double height; };
There are no pure virtual functions.
Select the false statement. The new operator:
Throws a bad_alloc exception regardless of what function is registered with set_new_handler.
Which of the following lines would be the prototype for an overloaded cast operator function that converts an object of user-defined type Time into a double?
Time::operator double() const;
End-of-line comments that should be ignored by the compiler are denoted using:
Two forward slashes (//).
Parameterized stream manipulator setfill specifies the fill character that's displayed when an output is displayed in a field wider than the number of characters or digits in the output. The effect of setfill applies:
Until explicitly set to a different setting.
To pop an element off the top of a stack for processing:
Use member function top and then member function pop.
To rethrow an exception, the exception handler must:
Use the throw; statement.
A function template can be overloaded by:
Using non-template functions with the same name and different parameters.
Which language was developed by Microsoft in the early 1990s to simplify the development of Windows applications?
Visual Basic.
[C++11]: Which of the following statements is true?
When opening a file, you can specify the name of the file as either a pointer-based string or a string object.
Which of the following statements is false?
Windows is an open source operating system.
The merge sort algorithm:
Works by merging two sorted vectors into one larger sorted vector.
Select the false statement. The write function:
Writes to files in hexadecimal format.
Which statement about operator overloading is false?
You can overload all C++ operators to be used with class objects.
Abstract classes do not necessarily have:
Zero references to their class.
Lambdas begin with the lambda introducer ________, followed by a parameter and function body.
[]
A pointer is a variable that contains as its value the ____________ of another variable.
address
Which of the following is not a sequence container provided by the Standard Library?
array
Which of the following statement is declaring an array, fractions, with arraySize elements of type double, and initialize the elements to 0?
array<double, arraySize> fractions{0.0};
Lists and tables of values can be stored in _________ or __________ .
arrays, vectors
Which of the following cannot be used to concatenate strings?
assign
Which bitset function could be used to create the logical not of a bitset object b?
b.flip()
Assuming that bitset b1 contains the bits [0 1 1 0] and bitset b2 contains the bits [1 1 1 1], which of the following expressions returns true?
b1.any()
The nodes of a(n) _________ tree contain two link members.
binary
The bits in the result of an expression using the operator are set to one if the ___________ corresponding bits in each operand are set to one. Otherwise, the bits are set to zero.
bitwise AND (&)
The bits in the result of an expression using the ___________ operator are set to one if at least one of the corresponding bits in either operand is set to one. Otherwise, the bits are set to zero.
bitwise inclusive OR (|)
What type of value is returned by the overloaded equality and relational operators for strings?
bool
Classes from which objects can be instantiated are called __________ classes.
concrete
Which of the following is false?
c_str returns a character array of the same length as the string object it is called on.
Lambdas return types ________.
can be inferred automatically if the body is a single statement of the form return expression; otherwise, the return type is void by default.
Which of the following is a valid generator function prototype for use with generate or generate_n on a vector<char>?
char nextLetter();
Each link in a tree node points to a(n) ________or __________of that node.
child or subtree
cin.getline(superstring, 30); is equivalent to which of the following?
cin.getline(superstring, 30, '\n');
Every class definition contains the keyword ________ followed immediately by the class's name.
class
To declare class subClass a privately derived class of superClass one would write:
class subclass : private superClass
Member function __________ of the file streams fstream, ifstream and ofstream closes a file.
close
The process of instructing the computer to solve a problem is called_______________.
computer programming
When each object of a class maintains its own version of an attribute, the variable that represents the attribute is also known as a(n) ______________.
data member.
If a member initializer is not provided for a member object of a class, the object's ________________ is called.
default constructor
The operator ___________ reclaims memory previously allocated by new.
delete
C++ programs normally go through six phases— _____, _________, __________, _______, _______, and _______________.
edit, preprocess, compile, link, load, execute
Which of the following returns a bool?
empty
The __________ algorithm compares two sequences of values for equality.
equal
Function _________ deletes characters from a string.
erase
Which of the following will not change the file-position pointer to the same position as the others? Assume a 10-byte file size and a current position at byte # 1.
fileObject.seekg(8, ios::end);
The easiest way to set all the values of a vector to zero is to use function:
fill
Algorithms _______ and ________ set every element in a range of container elements to a specific value.
fill, fill_n
Which algorithm cannot take a predicate function as an argument?
find
The easiest way to search through a list of names and output the first one that begins with a vowel would be to use function:
find_if
Which of the following searches through a string object from right-to-left?
find_last_of
A queue is referred to as a(n) ______________ data structure, because the first nodes inserted are the first nodes removed.
first-in, first-out (FIFO)
Which of the following would not be a member function that derived classes Fish, Frog and Bird should inherit from base class Animal and then provide their own definitions for, so that the function call can be performed polymorphically?
flapWings
Any algorithm that can receive a function pointer can also receive an object of a class that overloads the parentheses operator with a function named operator(), provided that the overloaded operator meets the requirements of the algorithm. An object of such a class is known as a(n) _________ and can be used syntactically and semantically like a function or function pointer.
function object
Templates enable us to specify, with a single code segment, an entire range of related functions called _______________ , or an entire range of related classes called ______________.
function-template specializations, class-template specializations
The isxdigit function would return false on:
g
Function _____________ from the <string> library reads characters until a newline character is encountered, then copies those characters into the specified string.
getline
In a(n) ______________ relationship, a class object has one or more objects of other classes as members.
has-a or composition or aggregation
The four traversal algorithms we mentioned in the text for binary search trees are__________, _________, _____________ and _____________.
inorder, preorder, postorder, level order
A linked list has the functions insertAtFront, removeFromFront, insertAtBack and removeFromBack, which perform operations on nodes exactly as their names describe. Which two functions would most naturally model the enqueue and dequeue operations, respectively, of a queue?
insertAtBack and removeFromFront.
Which of the following statements does not overwrite a preexisting value stored in a memory location?
int a;
Which statement would be used to declare a 10-element integer array c?
int c[10];
Which of the following is not a correct way to initialize a built-in array?
int n[5]{0, 7, 0, 3, 8, 2};
A bit field must be declared as a:
int or unsigned.
Suppose you have a programmer-defined data type Data and want to overload the << operator to output your data type to the screen in the form cout << dataToPrint; and allow cascaded function calls. The first line of the function definition would be:
ostream& operator<<(ostream& output, const Data& dataToPrint)
Which class indicates that an error occurred in which an arithmetic result was larger than the largest number that can be stored in the computer?
overflow_error.
[C++11]: To help prevent errors, apply C++11's ________ keyword to the prototype of every derived-class function that overrides a base-class virtual function.
override
A function that does not alter a linked list, but looks at the list to determine whether it's empty, is an example of a(n) ______________ function.
predicate
From most restrictive to least restrictive, the access modifiers are:
private, protected, public
When deriving a class from a protected base class, the public members of the base class become _________ and the protected members of the base class become __________?
protected, protected
When deriving from a class with protected inheritance, public members of the base class become ___________ members of the derived class, and protected members of the base class become ___________ members of the derived class.
protected, protected
A base class's ____________ members are accessible within that base class and anywhere that the program has a handle to an object of that class or one of its derived classes.
public
____________ class members are accessible anywhere an object of the class is in scope.
public
A base class's _________ and _____________ members can be accessed in the base-class definition, in derived-class definitions and in friends of the base class and derived classes.
public, protected
When deriving a class with public inheritance, public members of the base class become ___________ members of the derived class, and protected members of the base class become _____________ members of the derived class.
public, protected
5 / 5 pts The new C++14 stream manipulator ________ enables a program to read quoted text from a stream, including any white space characters in the quoted text, and discards the double quote delimiters. For example, if we read 100 "Janie Jones" 24.98 using inClientFile>> account>> quoted(name)>> balance; the first stream extraction reads 100 into the int variable account, the second reads Janie Jones as one string and stores it in the string variable name without the double-quote delimiters, and the third stream extraction reads 24.98 into the double variable balance.
quoted
The istream member function _______ is normally used when reading data from a file in random-access applications.
read
A self- ___________ class is used to form dynamic data structures that can grow and shrink at execution time
referential
Suppose you have a shopping list stored in a vector. What function would you use to remove all items in that vector that are under 10 dollars and place them in another container?
remove_copy_if
Which function changes the actual string stored in the string object (i.e., is not a const member function)?
resize
Given the strings defined below, which statement will not return 0? string s1{"Mighty Mouse"}; string s2{"Mickey Mouse"};
s1.compare(0, 3, s2, 0, 3);
If string s1 has the value "computer" and string s2 has the value "promise", which call to insert will produce the string "compromise"?
s2.insert(0, s1, 0, 3);
The process of determining if an array contains a particular key value is called ______________ the array.
searching
The __________ function would produce the sequence 1, 5, 6 when passed the sequences 1, 2, 3, 4, 5, 6 and 2, 3, 4, 7 as first/second and third/fourth arguments, respectively.
set_difference
The __________ function would produce a sequence containing three elements when passed the sequences 1, 2 and 1, 2, 3, 4, 5 as first/second and third/fourth arguments, respectively.
set_symmetric_difference
As of C++11, you can ask a vector or deque to return unneeded memory to the system by calling member function shrink_to_fit. This requests that the container reduce its capacity to the number of elements in the container. According to the C++ standard, implementations can ignore this request so that they can perform implementation-specific optimizations.
shrink_to_fit
The Standard Library container adapter most closely associated with the last-in, firstout (LIFO) insertion-and-removal discipline is the _________.
stack
Which of the following is not a kind of inheritance in C++?
static.
Class string belongs to the ________ namespace.
std
The ________ object enables a program to read data from the user.
std::cin.
Which of the following is not a syntax error?
std::cout << "Hello world! ";
Which of the following function calls is a valid way to place elements into vector<char> chars?
std::fill(chars.begin(), chars.end(), '5');
Which of the following function calls would not return the value that is its first argument?
std::max('d', 'k')
Which of the following correctly copies the contents of string2 into string1? Assume that string2 is equal to "goodbye" and string1 is equal to "good morning"?
strcpy(string1, string2);.
What is the code for a loop that iterates from the end of a string toward the beginning?
string::reverse_iterator i{s.rbegin()}; while (i != s.rend()) { cout << *i; --i; }
Which function would be the most useful for determining if a certain word is contained in a string representing a sentence?
strstr.
Keyword ____________ introduces a structure declaration.
struct
The number used to refer to a particular element of an array is called its ______________
subscript
Overridable functions are declared using keyword _______________.
virtual
to draw themselves, the draw function would most likely be declared:
virtual
If x initially contains the value 3, which of the following sets x to 7?
x += 4;
Which of the following C++ statement is not adding 1 to integer variable x.?
x =+ 1;
For any nonzero 8-bit x, which of the following does not result in zero?
x |= x
Assuming that x and y are equal to 3 and 2, respectively, after the statement x -= y executes, the values of x and y will be:
x: 1; y: 2
Assuming that x is equal to 4, which of the following statements will not result in y containing the value 5 after execution?
y = x++;