CISP400 Final

¡Supera tus tareas y exámenes ahora con Quizwiz!

What will be output by the following statements? A. 1.234500e-003 0.001235 B. 1.23450e-003 0.00123450 C. .001235 1.234500e-003 D. 0.00123450 1.23450e-003

C. .001235 1.234500e-003

memcmp would return ________ for the call memcmp("Hi, how are you?", "Hi, how are things?", 6). A. 1 B. A positive number. C. 0 D. A negative number.

C. 0

How many pointers are contained as data members in the nodes of a circular, doubly linked list of integers with five nodes? A. 5 B. 8 C. 10 D. 15

C. 10

If you have a 1000-element balanced binary search tree, what is the maximum number of comparisons that may be needed to find an element in the tree? A. 500 B. 20 C. 10 D. 8

C. 10

What will be output by the following statement? cout << showpoint << setprecision(4) << 11.0 << endl; A. 11 B. 11.0 C. 11.00 D. 11.000

C. 11.00

A double subscripted array element declared as a[ 3 ][ 5 ] has how many elements? A. 10. B. 13. C. 15. D. 8.

C. 15.

Which of the following statements is true? 1. In C++11, all classes can be used as base classes. 2. In C++11, only classes that are not declared as final can be used as base classes. 3. In C++11, only classes that are declared as base can be used as base classes. 4. None of these

. In C++11, only classes that are not declared as final can be used as base classes.

In order to calculate the ________ of an array of values, the array values must first be summed. 1. Average. 2. Minimum. 3. Maximum. 4. Distribution

.1. Average.

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? 1. "EF" 2. "EFGHI" 3. "CDEF" 4. "CD"

1. "EF"

Iterators are similar to pointers because of the: 1. * and ++ operators. 2. -> operator. 3. begin and end functions. 4. & operator.

1. * and ++ operators.

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: 1. *this.x 2. (*this).x 3. x 4. None of these are equivalent.

1. *this.x

Which of the following is not overloaded for strings? 1. -= 2. >> 3. += 4. getline()

1. -=

At most, how many comparisons are required to search a sorted vector of 1023 elements using the binary search algorithm? 1. 10 2. 15 3. 20 4. 30

1. 10

A class-scope variable hidden by a block-scope variable can be accessed by preceding the variable name with the class name followed by: 1. :: 2. : 3. . 4. ->

1. ::

In order to perform file processing in C++, which header files must be included? 1. <cstdio> , <iostream> and <fstream>. 2. <cstdio> and <iostream>. 3. <cstdio> and <fstream>. 4. <iostream> and <fstream>.

4. <iostream> and <fstream>.

Which of the following operators can be overloaded as a non-member function? 1. () 2. [] 3. += 4. ==

4. ==

If unexpected data is processed in an I/O operation: 1. An exception will be thrown. 2. An error message will automatically be displayed. 3. The program will terminate execution. 4. Various error bits will be set.

4. Various error bits will be set.

Abstract classes do not necessarily have: 1. A 0 pointer in their vtable. 2. A virtual function prototype with the notation = 0. 3. Zero instances of their class. 4. Zero references to their class.

4. Zero references to their class.

Which of the following cannot be used to concatenate strings? 1. + 2. += 3. append 4. assign

4. assign

Which of the following classes is deepest in the inheritance hierarchy? 1. basic_iostream 2. basic_ofstream 3. basic_ifstream 4. basic_fstream

4. basic_fstream

Which of the following character array declarations does not produce a string? 1. char string1[] = " ";. 2. char string1[] = "test";. 3. char string1[] = { 't', 'e', 's', 't', '\0' };. 4. char string1[] = { 't', 'e', 's', 't' };.

4. char string1[] = { 't', 'e', 's', 't' };.

Given the class definition: class CreateDestroy { public: CreateDestroy() { cout << "constructor called, "; } ~CreateDestroy() { cout << "destructor called, "; } }; What will the following program output? int main() { CreateDestroy c1; CreateDestroy c2; return 0; } 1. constructor called, destructor called, constructor called, destructor called, 2. constructor called, destructor called, 3. constructor called, constructor called, 4. constructor called, constructor called, destructor called, destructor called,

4. constructor called, constructor called, destructor called, destructor called,

Which of the following statements restores the default fill character? 1. cout.defaultFill(); 2. cout.fill(); 3. cout.fill( 0 ); 4. cout.fill( ' ' );

4. cout.fill( ' ' );

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? A. 3 B. 4 C. 5 D. 6

A. 3

Given the following declaration, what is the value of b[ 1 ][ 0 ]? int b[ 2 ][ 2 ] = { { 1 }, { 3 , 4 } }; A. 3. B. This is not a valid declaration. C. 1. D. 0.

A. 3.

Run-time type information can be used to determine: A function's return type. A function's argument type. An object's type. The number of arguments a function takes.

An object's type.

Evaluate ( 00001000 & 11000101 ) ^ ( 11110000 ). A. 00111101. B. 11110000. C. 00001101. D. 11000000.

B. 11110000.

The numbers 3, 2, 5, 7 are enqueued in a queue in that order, then three numbers are dequeued, and finally 3, 7, 9, 4 are enqueued in that order. What is the first number in the queue (the next number to be dequeued)? A. 4. B. 7. C. 9. D. 3.

B. 7.

The number 4 typically takes up _________ bit(s) when stored as a character on most of today's computers. A. Three. B. Eight. C. One. D. Four.

B. Eight.

A stack is initially empty, then the following commands are performed: push 5 push 7 pop push 10 push 5 pop Which of the following is the correct stack after those commands (assume the top of the stack is on the left)? A. 5 10 7 5 B. 5 10 C. 7 5 D. 10 5

D. 10 5

The functions of the character-handling library typically manipulate characters as: 1. ints 2. floats 3. longs 4. chars

1. ints

Which file open mode would be used to write data only at the end of an existing file? 1. ios::app 2. ios::in 3. ios::out 4. ios::trunc

1. ios::app

What is the output of the following statement? cout << strspn("Cows like to moo.", "Ceik losw"); 1. Nothing. 2. 10. 3. 8. 4. e.

2. 10.

The number of bits in a bit field is specified with: 1. Parentheses as in bitfield( 4 ) 2. A colon as in bitfield : 4 3. Brackets as in bitfield[ 4 ] 4. A dot as in bitfield.4

2. A colon as in bitfield : 4

Which of the following is not an abstract data type? 1. A used-defined class. 2. A for loop. 3. An ASCII character. 4. An int.

2. A for loop.

Given that v1 and v2 are vectors, what is returned by the function call std::equal( v1.begin(), v1.end(), v2.begin() ) 1. A bool indicating whether v1 and v2 are equal. 2. A bool indicating whether the first element of v1, the last element of v1 and the first element of v2 are all equal. 3. An iterator pointing to the first location where v1 and v2 are equal. 4. An iterator pointing to the first location where v1 and v2 are not equal.

1. A bool indicating whether v1 and v2 are equal.

Which of the following statements about friend functions and friend classes is false? 1. A class can either grant friendship to or take friendship from another class using the friend keyword. 2. A friend declaration can appear anywhere in a class definition. 3. A friend of a class can access all of its private data member and member functions. 4. The friendship relationship is neither symmetric nor transitive.

1. A class can either grant friendship to or take friendship from another class using the friend keyword.

An array name is: 1. A constant pointer to nonconstant data. 2. A nonconstant pointer to constant data. 3. A nonconstant pointer to nonconstant data. 4. A constant pointer to constant data.

1. A constant pointer to nonconstant data.

The putback member function returns to the input stream the previous character obtained by: 1. A get from the input stream. 2. Using the stream extraction operator on the input stream. 3. Reading input from the keyboard. 4. Reading a file from disk.

1. A get from the input stream.

Select the incorrect statement. 1. A non-template class can be used to derive a class-template specialization. 2. A class-template specialization can be used to derive a class template. 3. A non-template class can be derived from a class template-specialization. 4. A class template can be derived from a nontemplate class.

1. A non-template class can be used to derive a class-template specialization.

Which of the following is false? 1. A string can be defined to store any data type. 2. Class string provides bounds checking in its member function at. 3. Class string's overloaded [] operator returns a vector element as an rvalue or an lvalue, depending on the context. 4. An exception is thrown if the argument to string's at member function is an invalid subscript.

1. A string can be defined to store any data type.

________ is not allowed. 1. Accessing individual bits in a multi-bit bit field 2. Padding a bit field with bits that cannot be accessed 3. Having an unnamed bit field 4. Having a bit field with a zero width

1. Accessing individual bits in a multi-bit bit field

The line: virtual double earnings() const = 0; appears in a class definition. You cannot deduce that: 1. All classes that directly inherit from this class will override this method. 2. This class is an abstract class. 3. Any concrete class derived from this class will have an earnings function. 4. This class will probably be used as a base class for other classes.

1. All classes that directly inherit from this class will override this method.

Which of the following is not one of the disadvantages of not using exception-handling to deal with errors? 1. All of the above are disadvantages of not using exception-handling to deal with errors. 2. Intermixing program logic with error-handling logic can make the program more difficult to read, modify, maintain and debug. 3. Frequent tests for infrequently occurring errors can degrade a program's performance. 4. Programmers may delay writing error-processing code or sometimes forget to include it.

1. All of the above are disadvantages of not using exception-handling to deal with errors.

Function-template specializations: 1. Are generated at compile time. 2. Are identical to macros. 3. Have a maximum allowed number of type parameters. 4. Are not more concise than the equivalent set of overloaded functions.

1. Are generated at compile time.

Base class constructors and assignment operators: 1. Are not inherited by derived classes. 2. Should not be called by derived class constructors and assignment operators. 3. Can be inherited by derived classes, but generally are not. 4. Can call derived-class constructors and assignment operators.

1. Are not inherited by derived classes.

Utility functions: 1. Are private member functions that support operations of the class's other member functions. 2. Are part of a class's interface. 3. Are intended to be used by clients of a class. 4. Are a type of constructor.

1. Are private member functions that support operations of the class's other member functions.

A random access file is organized most like a(n): 1. Array. 2. Object. 3. Class. 4. Pointer.

1. Array.

Exception handling should not be used: 1. As an alternative for program control. 2. To make error handling uniform on large projects. 3. To deal with errors that do not arise very often. 4. To deal with errors for components that will be widely used in other applications, such as classes and libraries.

1. As an alternative for program control.

The purpose of stack unwinding is to: 1. Attempt to catch exceptions that are not caught in their scope. 2. Improve catch blocks by allowing them to handle multiple exceptions. 3. Return control to the function that created the exception. 4. Aid the terminate command in shutting down the program.

1. Attempt to catch exceptions that are not caught in their scope.

The line: virtual double functionX() const = 0; in a class definition indicates that the class is probably a: 1. Base class. 2. Derived class. 3. Protected class. 4. Library class.

1. Base class

When an object of a derived class is instantiated, the ________ constructor initializes the ________ members. 1. Base class, base class. 2. Derived class, base class. 3. Base class, derived class. 4. Derived class, public.

1. Base class, base class

The choice of which sorting algorithm to use does not affect: 1. How sorted the vector will be. 2. The time it takes for the sorting operation to complete. 3. The amount of memory used by the program. 4. All of these will be affected by the choice of sorting algorithm.

1. How sorted the vector will be

The is-a relationship represents. 1. Composition. 2. Inheritance. 3. Information hiding. 4. A friend.

2. Inheritance.

Which statement is false? 1. Based on whether an operator is implemented as a member function or as a non-member function, the operator is used differently in expressions. 2. When an operator function is implemented as a member function, the leftmost (or only) operand must be an object (or a reference to an object) of the operator's class. 3. Operator member functions of a specific class are called (implicitly by the compiler) only when the left operand of a binary operator is specifically an object of that class, or when the single operand of a unary operator is an object of that class. 4. Another reason why you might choose a non-member function to overload an operator is to enable the operator to be commutative

1. Based on whether an operator is implemented as a member function or as a non-member function, the operator is used differently in expressions.

Conversion constructors cannot: 1. Be used implicitly in series to match the needs of an overloaded operator. 2. Be applied implicitly. 3. Take exactly one argument. 4. Be used to convert the arguments for overloaded operators to the types needed by those overloaded operators.

1. Be used implicitly in series to match the needs of an overloaded operator.

The most basic unit of data on a computer is the: 1. Bit. 2. File. 3. Byte. 4. int.

1. Bit.

Which of the following is not a valid way to pass arguments to a function in C++? 1. By value with pointer arguments. 2. By value. 3. By reference with pointer arguments. 4. By reference with reference arguments.

1. By value with pointer arguments.

Function templates: 1. Can include objects of template classes as parameters. 2. Must have return type T. 3. Do not need a separate template< typename type > statement if they take objects from a template class as a parameter. 4. Do not need a separate template< typename type > statement.

1. Can include objects of template classes as parameters.

Referencing elements outside the array bounds with the [] operator: 1. Can result in changes to the value of an unrelated variable. 2. Is impossible because C++ checks to make sure it does not happen. 3. Is a syntax error. 4. Enlarges the size of the array.

1. Can result in changes to the value of an unrelated variable.

strings: 1. Can use the subscript operator to access individual characters. 2. Must be null-terminated. 3. Are pointers. 4. Have a first subscript of 1.

1. Can use the subscript operator to access individual characters.

Select the false statement. The reinterpret_cast operator: 1. Changes the value of the object to which its operand points. 2. Performs its operation at compile time. 3. Is compiler-dependent and can cause programs to behave differently on different platforms. 4. Is easy to use to perform dangerous manipulations that could lead to serious execution-time errors.

1. Changes the value of the object to which its operand points.

What kind of linked list begins with a pointer to the first node, and each node contains a pointer to the next node, and the pointer in the last node points back to the first node? 1. Circular, singly-linked list. 2. Circular, doubly-linked list. 3. Singly-linked list. 4. Doubly-linked list.

1. Circular, singly-linked list.

The relationship between function templates and function-template specializations is most similar to the relationship between: 1. Classes and objects. 2. Classes and functions. 3. Functions and return types. 4. Headers and source files.

1. Classes and objects.

A string array is commonly used for: 1. Command-line arguments. 2. Storing multiple copies of the same string. 3. Displaying floating-point numbers to the screen. 4. Storing an extremely long string.

1. Command-line arguments.

Which of the following is true about using inheritance in software engineering? 1. Common attributes and behaviors should be factored out of closely related classes and placed into a base class from which the original classes can now inherit. 2. It is best to create a huge class library to make it easy for a client to find the most appropriate class for his or her needs. 3. A class produced through inheritance should be as large as possible to fully encompass all of the functionality it should offer. 4. The standard C++ libraries that are shipped with C++ compilers are usually enough to accomplish anything an application might need to do.

1. Common attributes and behaviors should be factored out of closely related classes and placed into a base class from which the original classes can now inherit.

typedef is used to: 1. Create a type name that is an alias for another type name. 2. Make a struct private. 3. Cast one struct to another type. 4. Initialize struct members.

1. Create a type name that is an alias for another type name.

The stream-extraction operator: 1. Does not normally accept white-space characters. 2. Returns true when the end-of-file is encountered. 3. Sets the stream's failbit if the operation fails. 4. Sets the stream's badbit if the data is of the wrong type.

1. Does not normally accept white-space characters.

Which category of iterators combines the capabilities of input and output iterators into one iterator? 1. Forward iterators. 2. Bidirectional iterators. 3. Random access iterators. 4. Input/output iterators.

1. Forward iterators.

protected base class members cannot be accessed by: 1. Functions that are neither friends of the base class, derived-class member functions nor friends of a derived class. 2. friends of the base class. 3. Functions that are not derived-class member functions. 4. friends of derived classes.

1. Functions that are neither friends of the base class, derived-class member functions nor friends of a derived class.

Which of the following is not a correct way to initialize an array? 1. int n[ 5 ] = { 0, 7, 0, 3, 8, 2 };. 2. int n[ 5 ] = { 9, 1, 9 };. 3. int n[] = { 0, 7, 0, 3, 8, 2 };. 4. int n[ 5 ] = { 7 };.

1. int n[ 5 ] = { 0, 7, 0, 3, 8, 2 };.

The choice of which sorting algorithm to use does not affect: 1. How thoroughly sorted the vector will be. 2. The amount of memory used by the program. 3. All of the above will be affected by the choice of sorting algorithm. 4. The time it takes for the sorting operation to complete.

1. How thoroughly sorted the vector will be.

In general, linked lists allow: 1. Insertions and removals anywhere. 2. Insertions and removals only at one end. 3. Insertions at the back and removals from the front. 4. None of these.

1. 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 second line: 1. Invokes the CommissionEmployee constructor with arguments. 2. Causes a compiler error. 3. Is unnecessary because the CommissionEmployee constructor is called automatically. 4. Indicates inheritance.

1. Invokes the CommissionEmployee constructor with arguments.

Linear search is highly inefficient compared to binary search when dealing with: 1. Large, sorted arrays. 2. Large, unsorted arrays. 3. Small, unsorted arrays. 4. Small, sorted arrays.

1. Large, sorted arrays.

The pointer member in a self-referential class is referred to as a: 1. Link. 2. Connector. 3. Tie. 4. Referrer.

1. Link.

In a UML communication diagram, the first message passed during the processing of message 1 is called: 1. Message 1.1. 2. Message 2. 3. Message 1-1. 4. Message 0.

1. Message 1.1.

Once an exception is thrown, when can control return to the throw point? 1. Never. 2. Only after the exception is caught. 3. Once the stack unwinding process is completed. 4. Immediately after the exception is thrown.

1. Never.

Which of the following is not a valid runtime description according to Big O notation? 1. O(1/n). 2. O(n2). 3. O(n). 4. O(1).

1. O(1/n).

Suppose an algorithm contains three repetition statements, the second nested within the first and the third nested within the second. The first loop performs O(n) iterations, the second loop performs O(n2) iterations and the third loop performs O(n4) iterations. What is the Big O of the entire algorithm? 1. O(n^7). 2. O(n^4). 3. O(n). 4. O(n^8).

1. O(n^7).

Which of the following is not allowed? 1. Objects of abstract classes. 2. Multiple pure virtual functions in a single abstract class. 3. References to abstract classes. 4. Arrays of pointers to abstract classes.

1. Objects of abstract classes.

For a class template, the scope resolution operator (::) is needed: 1. Only in the definitions of the member functions defined outside the class. 2. Both in the prototype and definition of a member function. 3. Only if multiple class-template specializations will be created from this class template. 4. In neither the definition nor prototype of member functions.

1. Only in the definitions of the member functions defined outside the class.

Functions lower_bound, upper_bound and equal_range are different in their: 1. Return types. 2. First argument types. 3. Second argument types. 4. Third argument types.

1. Return types.

Which of the following is not an Standard Library container type? 1. Second-class containers. 2. Sequence containers. 3. Associative containers. 4. Container adapters.

1. Second-class containers.

Which of the following is not true? 1. String literals are written inside of single quotes. 2. A string in C++ is an array of characters ending in the null character ('\0'). 3. A string may be assigned in a declaration to either a character array or a variable of type char *. 4. A string may include letters, digits and various special characters (i.e., +, -, * ).

1. String literals are written inside of single quotes.

The for_each function applies a general function to each element in the specified range. This general function should: 1. Take an argument of the elements' type and return nothing. 2. Take an argument of the elements' type and return a value of the elements' type. 3. Take an argument of a non-const reference to the elements' type and return nothing. 4. Take an argument of a non-const reference to the elements' type and return a value of the elements' type.

1. Take an argument of the elements' type and return nothing

Which of the following operators cannot be overloaded? 1. The . operator. 2. The -> operator. 3. The & operator. 4. The [ ] operator.

1. The . operator.

An advantage of using inheritance with exceptions is: 1. The ability to catch related errors easily. 2. Allowing catch statements to be imported into classes. 3. The ability to explicitly test for derived class objects individually. 4. The simplification of destructor calls for objects.

1. The ability to catch related errors easily.

Which situation would require the operator to be overloaded as a global function? 1. The left operand is an int. 2. The left most operand must be a class object (or a reference to a class object). 3. The operator returns a reference. 4. The overloaded operator is =.

1. The left operand is an int.

An activation, represented by a thin vertical rectangle, on an object's lifeline indicates that: 1. The object is executing. 2. The object is waiting for another object to return control. 3. The object is instantiated in memory. 4. The object has terminated execution.

1. The object is executing.

Which of the following is not true about bool values and how they're output with the output stream? 1. The old style of representing true/false values used -1 to indicate false and 1 to indicate true. 2. A bool value outputs as 0 or 1 by default. 3. Stream manipulator boolalpha sets the output stream to display bool values as the strings "true" and "false". 4. Both boolalpha and noboolalpha are "sticky" settings.

1. The old style of representing true/false values used -1 to indicate false and 1 to indicate true.

A bit field must be declared as a: 1. int or unsigned 2. char 3. float 4. long

1. int or unsigned

The arguments passed to replace do not include: 1. The subscript of the element where the replace operation ends. 2. The subscript of the element where the replace operation begins. 3. A replacement character string from which a substring is used to replace characters. 4. The element in the replacement character string where the replacement substring begins.

1. The subscript of the element where the replace operation ends.

The main difference between the functions atof, atoi and atol is: 1. Their return types. 2. Their arguments. 3. Their header files. 4. Their efficiency.

1. Their return types.

What mistakes 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; }; 1. There are no pure virtual functions. 2. There is a non-virtual function. 3. private variables are being accessed by a public function. 4. Nothing, it functions fine as an abstract class.

1. There are no pure virtual functions.

The difference between the operator! member function and the operator void* member function is that: 1. They always return opposite boolean values. 2. They occasionally return opposite boolean values. 3. Of the two member functions, only operator! checks if eof has been set. 4. Of the two member functions, only operator void* checks if eof has been set.

1. They always return opposite boolean values.

Comparing pointers and performing pointer arithmetic on them is meaningless unless: 1. They point to elements of the same array. 2. You are trying to compare and perform pointer arithmetic on the values to which they point. 3. They point to arrays of equal size. 4. They point to arrays of the same type.

1. They point to elements of the same array.

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? 1. Time::operator double() const; 2. Time::static_cast double() const; 3. Time::operator_cast(double) const; 4. Time::double() const;

1. Time::operator double() const;

To rethrow an exception, the exception handler must: 1. Use the throw; statement. 2. Use the throw command with the same parameters as the original exception. 3. Return a reference to whatever caused the original exception. 4. Not have attempted to process that exception at all.

1. Use the throw; statement.

Instead of including a string data type among C++'s built-in data types, C++: 1. Was designed to include mechanisms for creating and implementing string abstract data types through classes. 2. Forces the programmer to make do with char array strings. 3. None of the above. 4. Chose to ignore the need for a string data type.

1. Was designed to include mechanisms for creating and implementing string abstract data types through classes.

The main difference between structures and classes is: 1. Whether they default to public or private access. 2. How they access member variables. 3. That classes always require new be used with them while structures do not. 4. There is no difference between structures and classes.

1. Whether they default to public or private access.

Employee is a base class and HourlyWorker is a derived class, with a redefined non-virtual print function. Given the following statements, will the output of the two print function calls be identical? HourlyWorker h; Employee *ePtr = &h; ePtr->print(); ePtr->Employee::print(); 1. Yes. 2. Yes, if print is a static function. 3. No. 4. It would depend on the implementation of the print function.

1. Yes.

Lambdas begin with the lambda introducer ________, followed by a parameter and function body. 1. [] 2. () 3. {} 4. <>

1. []

Which of the following provides bounds checking? 1. at 2. iterator 3. reverse_iterator 4. [ ]

1. at

Which of the following is most likely a base class of the other three? 1. automobile. 2. convertible. 3. miniVan. 4. sedan.

1. automobile.

Which of the following classes is a base class of the other three? 1. basic_ios 2. basic_istream 3. basic_ostream 4. basic_iostream

1. basic_ios

To declare class subClass a privately derived class of superClass one would write: 1. class subclass : private superClass 2. class subclass :: private superClass 3. class subclass < private superClass > 4. class subclass inherits private superClass

1. class subclass : private superClass

Given the class definition: class CreateDestroy { public: CreateDestroy() { cout << "constructor called, "; } ~CreateDestroy() { cout << "destructor called, "; } }; What will the following program output? int main() { for ( int i = 1; i <= 2; i++ ) CreateDestroy cd; return 0; } 1. constructor called, destructor called, constructor called, destructor called, 2. constructor called, constructor called, 3. constructor called, constructor called, destructor called, destructor called, 4. Nothing.

1. constructor called, destructor called, constructor called, destructor called,

The code fragment: Increment::Increment( int c, int i ) : increment ( i ) { count = c; } does not cause any compilation errors. This tells you that: 1. count must be a non-const variable. 2. count must be a const variable. 3. increment must be a non-const variable. 4. increment must be a const variable.

1. count must be a non-const variable.

Part of the functionality of member function ________ can be performed by member function lower_bound. 1. equal_range 2. find 3. count 4. insert

1. equal_range

Which algorithm cannot take a predicate function as an argument? 1. find 2. find_if 3. sort 4. binary_search

1. find

Which of the following libraries does not deal with input/output? 1. fiostream. 2. iostream. 3. iomanip. 4. fstream.

1. fiostream.

Which of the following is not a correct way to initialize a built-in array? 1. int n[ 5 ] = { 0, 7, 0, 3, 8, 2 }; 2. int n[] = { 0, 7, 0, 3, 8, 2 }; 3. int n[ 5 ] = { 7 }; 4. int n[ 5 ] = { 9, 1, 9 };

1. int n[ 5 ] = { 0, 7, 0, 3, 8, 2 };

For a non-empty linked list, select the code that should appear in a function that adds a node to the end of the list. newPtr is a pointer to the new node to be added and lastPtr is a pointer to the current last node. Each node contains a pointer nextPtr. 1. lastPtr->nextPtr = newPtr; lastPtr = newPtr 2. lastPtr = newPtr; lastPtr->nextPtr = newPtr 3. newPtr->nextPtr = lastPtr; lastPtr = newPtr 4. lastPtr = newPtr; newPtr->nextPtr = lastPtr

1. lastPtr->nextPtr = newPtr; lastPtr = newPtr

To change the string "ABCDEFGHI" to "aaaaaFGHI" you would use the ________ function. 1. memset 2. memcmp 3. memchr 4. memcopy

1. memset

The correct function name for overloading the addition (+) operator is: 1. operator+ 2. operator(+) 3. operator:+ 4. operator_+

1. operator+

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: 1. ostream operator<<( ostream &output, const Data &dataToPrint ). 2. ostream &operator<<( ostream &output, const Data &dataToPrint ). 3. ostream &operator<<( const Data &dataToPrint, ostream &output ). 4. ostream operator<<( const Data &dataToPrint, ostream &output ).

1. ostream operator<<( ostream &output, const Data &dataToPrint ).

Which of the following is a valid user-defined output stream manipulator header? 1. ostream& tab( ostream& output ) 2. ostream tab( ostream output ) 3. istream& tab( istream output ) 4. void tab( ostream& output )

1. ostream& tab( ostream& output )

Suppose the unary ! operator is an overloaded member function of class String. For a String object s, which function call is generated by the compiler when it finds the expression !s? 1. s.operator!() 2. s.operator!( default_value1, default_value2, ) 3. operator!( s ) 4. A compiler error results because no arguments are given.

1. s.operator!()

Given the strings defined below, which statement will not return 0? string s1 = "Mighty Mouse"; string s2 = "Mickey Mouse"; 1. s1.compare(0, 3, S2, 0, 3); 2. s1.compare(7, 5, S2, 7, 5); 3. s1.compare(8, 12, S2, 8, 12); 4. s1.compare(7, 11, S2, 7, 11);

1. s1.compare(0, 3, S2, 0, 3);

Which of the following function calls is a valid way to place elements into vector< char > chars? 1. std::fill( chars.begin(), chars.end(), '5' ); 2. std::fill_n( chars.begin(), chars.end(), '5' ); 3. std::generate( chars.begin(), 10, '5' ); 4. std::generate_n( 10, chars.end(), '5' );

1. std::fill( chars.begin(), chars.end(), '5' );

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"? 1. strcpy( string1, string2 ); 2. strcpy( string1, string2, 6 ); 3. strncpy( string1, string2, 5 ); 4. strncpy( string1, string2, 6 );

1. strcpy( string1, string2 );

What is the code for a loop that iterates from the end of a string toward the beginning? 1. string::reverse_iterator i = s.rbegin() while ( i != s.rend() ) { cout << *i; --i; }. 2. string::reverse_iterator i = s.end() while ( i != s.begin() ) { cout << *i; --i; }. 3. string::reverse_iterator i = s.begin() while ( i != s.end() ) { cout << *i; ++i; } 4. string::reverse_iterator i = s.rbegin() while ( i != s.rend() ) { cout << *i; ++i; }.

1. string::reverse_iterator i = s.rbegin() while ( i != s.rend() ) { cout << *i; --i; }.

Assume that t is an object of class Test, which has member functions a(), b(), c() and d(). If the functions a(), b() and c() all return references to an object of class Test (using the dereferenced this pointer) and function d() returns void, which of the following statements will not produce a syntax error: 1. t.a().b().d(); 2. a().b().t; 3. t.d().c(); 4. t.a().t.d();

1. t.a().b().d();

The ________ operator returns a reference to a ________ object: 1. typeid, type_info 2. typeinfo, type_id 3. typeid, data_type 4. typeinfo, type

1. typeid, type_info

Which operator keyword corresponds to ^? 1. xor 2. xor_eq 3. or 4. or_eq

1. xor

Assuming that t is an array and tPtr is a pointer to that array, which expression refers to the address of the fourth element? 1. tPtr[ 3 ]. 2. &t[ 3 ]. 3. *( tPtr + 3 ). 4. *( t + 3 ).

2. &t[ 3 ].

Which of the following can have a pointer as an operand? 1. /. 2. ++. 3. *=. 4. %.

2. ++.

If dynamic memory has been allocated for an object and an exception occurs, then: 1. The catch block will not work properly. 2. A memory leak could result. 3. The object's constructor will cause another exception. 4. Multiple pointers to memory could be created.

2. A memory leak could result.

A function that prints a string by using pointer arithmetic such as ++ptr to output each character should have a parameter that is: 1. A nonconstant pointer to nonconstant data. 2. A nonconstant pointer to constant data. 3. A constant pointer to nonconstant data. 4. A constant pointer to constant data.

2. A nonconstant pointer to constant data

A pointer can not be assigned to: 1. Another pointer of the same type without using the cast operator. 2. A pointer of a type other than its own type and void without using the cast operator. 3. Any other pointer by using the cast operator. 4. A pointer to void without using the cast operator.

2. A pointer of a type other than its own type and void without using the cast operator.

All of the following are true of an ostringstream object except that: 1. It uses a string to store output data. 2. A stream insertion operation cannot be used to append additional data to it. 3. The string data it stores is dynamically allocated. 4. The data it stores can be accessed using the function str.

2. A stream insertion operation cannot be used to append additional data to it.

Which of the following is not true of class template vector? 1. A vector can be assigned to another vector by using the assignment operator. 2. A vector can only store data type int. 3. The size of a vector can be changed after it is declared. 4. A vector object can be initialized with a copy of another vector by invoking the copy constructor.

2. A vector can only store data type int.

Select the false statement regarding exceptions. 1. The C++ standard has a hierarchy of exception classes. 2. All exception classes are accessible via <exception>. 3. Several classes derive from class exception. 4. The what function can be overridden in each class derived from exception.

2. All exception classes are accessible via <exception>.

Function template back_inserter returns: 1. A container. 2. An iterator for a container. 3. An element in a container. 4. A reference to an element in a container.

2. An iterator for a container.

Which of the following applications would a deque not be well suited for? 1. Applications that require frequent insertions and deletions at the front of a container. 2. Applications that require frequent insertions and deletions in the middle of a container. 3. Applications that require frequent insertions and deletions at the back of a container. 4. Applications that require frequent insertions and deletions at the front and at the back of a container.

2. Applications that require frequent insertions and deletions in the middle of a container.

Which of the following assignments would be a compilation error? 1. Assigning the address of a base-class object to a base-class pointer. 2. Assigning the address of a base-class object to a derived-class pointer. 3. Assigning the address of a derived-class object to a base-class pointer. 4. Assigning the address of a derived-class object to a derived-class pointer.

2. Assigning the address of a base-class object to a derived-class pointer.

Which of the following statements about searching algorithms and their efficiency is false? 1. The major difference between various searching algorithms is the amount of effort they require to complete the search. 2. Big O notation is one way to describe how likely it is that a searching algorithm will find its target. 3. The effort required to perform a search or a sort is particularly dependent on the number of data elements. 4. A more efficient searching algorithm is usually more complex and difficult to implement.

2. Big O notation is one way to describe how likely it is that a searching algorithm will find its target.

Unless otherwise specified, entire arrays are passed __________ and individual array elements are passed 1. By reference, by reference. 2. By reference, by value. 3. By value, by reference. 4. By value, by value.

2. By reference, by value.

Select the false statement. 1. C++ imposes no structure on a file. 2. C++ files include information about their structure. 3. The programmer must impose a structure on a file. 4. C++ files do not understand notions such as "records" and "fields."

2. C++ files include information about their structure.

Which of the following statements is false? 1. The C++ standard redesigned the classic C++ stream classes, which processed only chars, as class templates with specializations for processing characters of types char and wchar_t, respectively. 2. C++11 added type char64_t to handle the new double-width Unicode characters. 3. The size of type wchar_t is not specified by the C++ standard. 4. C++11's new char16_t and char32_t types for representing Unicode characters were added to provide character types with explicitly specified sizes.

2. C++11 added type char64_t to handle the new double-width Unicode characters.

If a member function of a class already provides all or part of the functionality required by a constructor or another member function then: 1. Copy and paste that member function's code into this constructor or member function. 2. Call that member function from this constructor or member function. 3. That member function is unnecessary. 4. This constructor or member function is unnecessary.

2. Call that member function from this constructor or member function.

static member functions: 1. Can use the this pointer. 2. Can access only other static member functions and static data members. 3. Cannot be called until an object of their class is instantiated. 4. Can be declared const as well.

2. Can access only other static member functions and static data members.

Conversion constructors: 1. Can have multiple arguments. 2. Can convert between user-defined types. 3. Are implicitly defined by the compiler if not explicitly written by the programmer. 4. Cannot convert built-in types to user defined types.

2. Can convert between user-defined types.

Which statement about operator overloading is false? 1. New operators can never be created. 2. Certain overloaded operators can change the number of arguments they take. 3. The precedence of an operator cannot be changed by overloading. 4. Overloading cannot change how an operator works on built-in types.

2. Certain overloaded operators can change the number of arguments they take.

If the line: friend class A; appears in class B, and the line: friend class B; appears in class C, then: 1. Class A is a friend of class C. 2. Class A can access private variables of class B. 3. Class C can call class A's private member functions. 4. Class B can access class A's private variables.

2. Class A can access private variables of class B

The first step performed by the binary search algorithm at each iteration is to: 1. Compare the search key with the lowest element in the current subvector. 2. Compare the search key with the middle element in the current subvector. 3. Compare the search key with the highest element in the current subvector. 4. Count the number of elements in the current subvector.

2. Compare the search key with the middle element in the current subvector.

strtok does not: 1. Replace each delimiting character with '\0'. 2. Completely tokenize the string the first time it is called. 3. Modify the input string. 4. Return a pointer to the token it creates.

2. Completely tokenize the string the first time it is called.

The assignment operator (=) can be used to: 1. Test for equality. 2. Copy data from one object to another. 3. Compare two objects. 4. Copy a class.

2. Copy data from one object to another.

Which is the proper way to create a built-in array of structure variables of type Data? 1. MyArray Data[ 10 ] 2. Data MyArray[ 10 ]; 3. Data struct myArray[ 10 ]; 4. struct MyArray[ Data ];

2. Data MyArray[ 10 ];

When the showbase flag is set: 1. The base of a number precedes it in brackets. 2. Decimal numbers are not output any differently. 3. "oct" or "hex" will be displayed in the output stream. 4. Octal numbers can appear in one of two ways.

2. Decimal numbers are not output any differently.

Using square brackets ([]) to retrieve vector elements __________ perform bounds checking; using member function at to retrieve vector elements __________ perform bounds checking. 1. Does, does not. 2. Does not, does. 3. Does, does. 4. Does not, does not.

2. Does not, does.

Which of the following statements is true of a priority_queue? 1. It does not allow insertions in sorted order. 2. Each of its common operations is implemented as an inline function. 3. A bucket sort is usually associated with it. 4. It must be implemented as a deque.

2. Each of its common operations is implemented as an inline function.

The try block cannot: 1. Enclose the code that may throw the exception. 2. Enclose its own catch blocks. 3. Test enclosing try blocks for additional catch statements if this try block's catch statements can't match the exception being thrown. 4. Have exceptions explicitly or implicitly thrown in the try block itself.

2. Enclose its own catch block

Select the false statement. If an exception is thrown from a constructor: 1. The object being constructed will not be constructed. 2. For an array, destructors for all array elements are called, even if those array elements have not yet been constructed. 3. The exception can contain the error information that the constructor would not be able to return in the normal manner. 4. For an object with member objects, and whose outer object has not been constructed, the destructor is called for the member objects.

2. For an array, destructors for all array elements are called, even if those array elements have not yet been constructed.

Every object of the same class: 1. Gets a copy of every member function and member variable. 2. Gets a copy of every member variable. 3. Gets a copy of every member function. 4. Shares pointers to all member variables and member functions.

2. Gets a copy of every member variable.

An abstract class will: 1. Have all zeros in its vtable. 2. Have at least one 0 in its vtable. 3. Share a vtable with a derived class. 4. Have fewer 0's in its vtable than concrete classes have.

2. Have at least one 0 in its vtable.

The C++ compiler makes objects take up more space in memory if they: 1. Are derived from base classes. 2. Have virtual functions. 3. Have only protected members. 4. Are referenced by pointers.

2. Have virtual functions.

Which of the following statements about inheriting base class constructors is false? 1. To inherit a base class's constructors, you write the following line of code in the derived class definition (BaseClass is the base class's name): 2. 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. 3. By default, each inherited constructor has the same access level (public, protected or private) as its corresponding base-class constructor. 4. If the derived class does not explicitly define constructors, the compiler generates a default constructor in the derived class-even if it inherits other constructors from its base class.

2. 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.

Member access specifiers (public and private) can appear: 1. In any order and multiple times, if they have brackets separating each type. 2. In any order and multiple times. 3. Outside a class definition. 4. In any order (public first or private first) but not multiple times.

2. In any order and multiple times.

Proxy classes are best described as an example of: 1. Structured programming. 2. Information hiding. 3. Object-oriented programming (as used in the text). 4. Utility functions.

2. Information hiding.

A copy constructor: 1. Is a constructor with only default arguments. 2. Is a constructor that initializes a newly declared object to the value of an existing object of the same class. 3. Is a constructor that takes no arguments. 4. None of these.

2. Is a constructor that initializes a newly declared object to the value of an existing object of the same class.

Which of the following is false about the new operator and the object for which it allocates memory? 1. It returns a pointer. 2. It automatically destroys the object after main is exited. 3. It does not require the size of the object to be explicitly specified in the new expression. 4. It calls the object's constructor.

2. It automatically destroys the object after main is exited.

Which of the following is false about a function to which an array is being passed? 1. It is able to modify the values stored in the array. 2. It knows the size of the array that is being passed. 3. It is being passed the address of the first element in the array. 4. The array name is used as an argument in the function call.

2. It knows the size of the array that is being passed.

________ is usually faster than ________. 1. High-level I/O, low-level I/O 2. Low-level I/O, high-level I/O 3. Low-level I/O, internal data processing 4. High-level I/O, internal data processing

2. Low-level I/O, high-level I/O

Class templates: 1. May include the statement template< typename Type > anywhere. 2. Must put template< typename Type > before the class definition. 3. Must include template< typename Type > inside the class definition. 4. Have the option of including the optional statement template< typename Type >.

2. Must put template< typename Type > before the class definition.

Selection sort has a Big O of: 1. O(2n) 2. O(n^2) 3. O(½n^2) 4. O((n^2 - n)/2 )

2. O(n^2)

What does the following statement declare? int *countPtr, count; 1. Two int variables. 2. One pointer to an int and one int variable. 3. Two pointers to ints. 4. The declaration is invalid.

2. One pointer to an int and one int variable.

A copy constructor must receive its argument by reference because: 1. Otherwise the constructor will only make a copy of a pointer to an object. 2. Otherwise infinite recursion occurs. 3. The copy of the argument passed by value has function scope. 4. The pointer needs to know the address of the original data, not a temporary copy of it.

2. Otherwise infinite recursion occurs.

Arrays are: 1. Always passed by reference. 2. Passed by reference unless inside a structure. 3. Passed by reference unless their elements are structures. 4. Always passed by value.

2. Passed by reference unless inside a structure.

A client changing the values of private data members is: 1. Only possible by calling private member functions. 2. Possible using public functions and references. 3. Never possible. 4. Only possible if the private variables are not declared inside the class.

2. Possible using public functions and references.

Which data structure represents a waiting line and limits insertions to be made at the back of the data structure and limits removals to be made from the front? 1. Stack. 2. Queue. 3. Binary tree. 4. Linked list.

2. Queue.

Separating Implementation from Interface ,br> 9.4 Q1: When independent software vendors provide class libraries to clients, they typically give the __________ for the class's interface and the __________ for the class's implementation. 1. Source code file, source code file. 2. Source code file, object module file. 3. Object module file, object module file. 4. Object module file, source code file.

2. Source code file, object module file.

Theoretically, clients do not need to see the ________ of classes from which they derive other classes. 1. Header files. 2. Source code. 3. Object code. 4. Interface.

2. Source code.

The erase member function of class vector cannot: 1. Specify an element to be removed from the vector. 2. Specify a value to be removed from the vector. 3. Specify a range of elements to be removed from the vector. 4. Be called by member function clear.

2. Specify a value to be removed from the vector.

Which of the following statements about stacks is incorrect? 1. Stacks can be implemented using linked lists. 2. Stacks are first-in, first-out (FIFO) data structures. 3. New nodes can only be added to the top of the stack. 4. The last node (at the bottom) of a stack has a null (0) link.

2. Stacks are first-in, first-out (FIFO) data structures.

Which of the following is not a member function of the C++ ostream class? 1. Stream-insertion operator (<<). 2. Stream-extraction operator (>>). 3. put. 4. write.

2. Stream-extraction operator (>>).

The capabilities of inputting and outputting strings in memory are known as: 1. String i/o manipulation. 2. String stream processing. 3. Character handling. 4. Dynamic string operations.

2. String stream processing.

An exception: 1. Terminates program execution. 2. Terminates the block where the exception occurred. 3. Will terminate the block where the exception occurred unless a catch command stops it. 4. Will not terminate a block unless explicitly instructed to do so.

2. Terminates the block where the exception occurred.

For a non-constant member function of class Test, the this pointer has type: 1. const Test * 2. Test * const 3. Test const * 4. const Test * const

2. Test * const

If Americans are objects of the same class, which of the following attributes would most likely be represented by a static variable of that class? 1. Age. 2. The President. 3. Place of birth. 4. Favorite food.

2. The President.

What type of value is returned by the overloaded equality and relational operators for strings? 1. int 2. bool 3. double 4. null

2. bool

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? 1. results1 contains more elements than results2. 2. The first element in results1 matches the last element in results2. 3. results1 is empty but results2 is not. 4. None of these.

2. The first element in results1 matches the last element in results2.

At the ith iteration of the insertion sort: 1. The ith element of the array is currently empty. 2. The first i elements of the array are sorted. 3. The ith element of the array is in its final position. 4. The last i elements of the array are sorted.

2. The first i elements of the array are sorted.

One difference between the three-argument version of the get function and the getline function is that: 1. Only get has a delimiter. 2. The getline function removes the delimiter from the stream. 3. Only get adds the delimiter to the array. 4. getline stores the characters it reads into its character array argument.

2. The getline function removes the delimiter from the stream.

In addition to hiding the implementation details that the ordinary method of "separating implementation from interface" would hide, using a proxy class also hides: 1. The definition of access functions. 2. The names of private data members. 3. The definition of constructors and the destructor. 4. The definition of inline functions.

2. The names of private data members.

In a typical nested for loop structure used to process a two-dimensional array, following the end of the each execution of the inner for loop: 1. The outer for loop initializes its counter variable. 2. The outer for loop increments its counter variable. 3. The inner for loop increments its counter variable. 4. The inner for loop initializes its counter variable.

2. The outer for loop increments its counter variable.

Given that the line delete newPtr; just executed, what can you conclude? 1. The memory referenced by newPtr is released only if it is needed by the system. 2. The pointer newPtr still exists. 3. The pointer newPtr only exists if there was an error freeing the memory. 4. The pointer newPtr is of type void *.

2. The pointer newPtr still exists.

Let x be an unsigned int on a machine with 4-byte unsigned ints. What effect does x>>=1; x<<=1; have? 1. The leftmost bit of x is set to 0. 2. The rightmost bit of x is set to 0. 3. Both (b) and (c). 4. There is no effect.

2. The rightmost bit of x is set to 0.

Which of the following statements is false? 1. You can overload a classes constructors. 2. There is no mechanism in C++ for a constructor to call another constructor in the same class. 3. Just as a constructor can call a class's other member functions to perform tasks, C++11 allows constructors to call other constructors in the same class. 4. To overload a constructor, provide in the class definition a prototype for each version of the constructor, and provide a separate constructor definition for each overloaded version.

2. There is no mechanism in C++ for a constructor to call another constructor in the same class.

Which of the following is not true about declaring references to objects of other classes inside a class definition? 1. If the class names for the other objects are used only to declare these references, a forward declaration can replace the #include statement usually used to include those classes' header files. 2. These references can be initialized inside the class definition. 3. These references can represent directional associations from a UML class diagram. 4. Each reference only requires enough memory to store the memory address of the object it references.

2. These references can be initialized inside the class definition.

The conventional way to distinguish between the overloaded preincrement and postincrement operators (++) is: 1. To assign a dummy value to preincrement. 2. To make the argument list of postincrement include an int. 3. To have the postincrement operator call the preincrement operator. 4. Implicitly done by the compiler.

2. To make the argument list of postincrement include an int.

A function template can be overloaded by: 1. Using other function templates with the same function name and parameters. 2. Using non-template functions with the same name and different parameters. 3. Using non-template functions with a different name but the same parameters. 4. Using other function templates with a different name but the same parameters.

2. Using non-template functions with the same name and different parameters.

Which statement about class unique_ptr (of the new C++ standard) and dynamic memory allocation is false? 1. An object of class unique_ptr maintains a pointer to dynamically allocated memory. 2. When a unique_ptr object destructor is called (for example, when a unique_ptr object goes out of scope), it performs a destroy operation on its pointer data member. 3. Class template unique_ptr provides overloaded operators * and -> so that a unique_ptr object can be used just as a regular pointer variable is. 4. Class unique_ptr is part of the new C++ standard and it replaces the deprecated auto_ptr class.

2. When a unique_ptr object destructor is called (for example, when a unique_ptr object goes out of scope), it performs a destroy operation on its pointer data member.

Which of the following is not a case in which function terminate is called? 1. When the exception mechanism cannot find a matching catch for a thrown exception. 2. When the abort function is called before any call to function set_abort. 3. When a destructor attempts to throw an exception during stack unwinding. 4. When an attempt is made to rethrow an exception when there is no exception currently being handled.

2. When the abort function is called before any call to function set_abort.

Which of the following is not a sequence container provided by the Standard Library? 1. vector 2. array 3. list 4. deque

2. array

Assuming that int a has a value of 3 and that integer array b has 7 elements, what is the correct way to assign the value of the third element plus 3, to the fifth element of the array: 1. b[ a + 1 ] = b[ a ] + 3;. 2. b[ a + 1 ] = b[ a - 1 ] + 3; 3. b[ a + 2 ] = b[ a ] + 3;. 4. b[ a ] + 1 = b[ a + 3];.

2. b[ a + 1 ] = b[ a - 1 ] + 3;

Lambdas return types: 1. cannot be inferred. 2. can be inferred automatically if the body is a single statement of the form return expression; otherwise, the return type is void by default. 3. are always void. 4. None of these.

2. 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 >? 1. void nextLetter(); 2. char nextLetter(); 3. char nextLetter( char ); 4. char nextLetter( int );

2. char nextLetter();

cin.getline( superstring, 30 ); is equivalent to which of the following? 1. cin.getline( superstring, 30, '\0' ); 2. cin.getline( superstring, 30, '\n' ); 3. cin.getline( superstring, 30, '\s' ); 4. cin.getline( superstring, 30, '\t' );

2. cin.getline( superstring, 30, '\n' );

Which of the following is a self-referential object? 1. class selfRefer { selfRefer x; };. 2. class selfRefer { SelfRefer * x; };. 3. class selfRefer1 { selfRefer2 x; };. 4. class selfRefer2 { selfRefer1 x; };. class selfRefer { int * x; };.

2. class selfRefer { SelfRefer * x; };.

Which of the following is not a mathematical algorithm included in the Standard Library? 1. min_element 2. copy 3. transform 4. accumulate

2. copy

virtual destructors must be used when: 1. The constructor in the base class is virtual. 2. delete is used on a base-class pointer to a derived-class object. 3. delete is used on a derived-class object. 4. A constructor in either the base class or derived class is virtual.

2. delete is used on a base-class pointer to a derived-class object.

Which of the following returns a bool? 1. length 2. empty 3. capacity 4. resize

2. empty

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: 1. find 2. find_if 3. sort 4. binary_search

2. find_if

Select the proper object type. ________ file( "file.dat", ios::in | ios::out ); 1. iostream 2. fstream 3. ofstream 4. ifstream

2. fstream

Which of the following is not an error-handling technique? 1. set_new_handler. 2. ifndef. 3. exit. 4. longjump.

2. ifndef.

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? 1. insertAtBack and removeFromBack. 2. insertAtBack and removeFromFront. 3. removeFromFront and insertAtFront. 4. removeFromFront and insertAtBack.

2. insertAtBack and removeFromFront.

When a compiler encounters a function parameter for a single-subscripted array of the form int a[], it converts the parameter to: 1. No conversion is necessary. 2. int * a. 3. int &a. 4. int a.

2. int * a.

What is not true about this code segment? location = fileObject.tellg(); 1. tellg is a member function of fileObject. 2. location is a pointer. 3. The value of location after the segment executes must be less than or equal to the number of bytes in the file attached to fileObject. 4. fileObject is an istream object.

2. location is a pointer.

Which of the following is not a member function of all sequence containers? 1. front 2. middle 3. back 4. pop_back

2. middle

The __________ operator takes as an argument the type of object being allocated and returns a __________. 1. sizeof, reference to an object of that type. 2. new, pointer to an object of that type. 3. delete, reference to an object of that type. 4. delete, copy of the object of that type.

2. new, pointer to an object of that type.

Function objects have their functions called by using: 1. The dot operator (.) 2. operator() 3. The arrow operator (->) 4. The binary scope resolution operator (::)

2. operator()

From most restrictive to least restrictive, the access modifiers are: 1. protected, private, public 2. private, protected, public 3. private, public, protected 4. protected, public, private

2. private, protected, public

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. 1. set_intersection 2. set_difference 3. set_union 4. set_symmetric_difference

2. set_difference

Which of the following bitset member functions cannot be called with an empty argument list? 1. reset 2. test 3. size 4. none

2. test

When using exception handling, place any code that might throw an exception in a ________. 1. catch block 2. try statement 3. throw block 4. what statement

2. try statement

If objects of all the classes derived from the same base class all need to draw themselves, the draw function would most likely be declared: 1. private 2. virtual 3. protected 4. friend

2. virtual

Polymorphism is implemented via: 1. Member functions. 2. virtual functions and dynamic binding. 3. inline functions. 4. Non-virtual functions.

2. virtual functions and dynamic binding.

For any 8-bit x, which of the following does not result in zero? 1. x <<= 8. 2. x |= x. 3. x ^= x. 4. x &= ( ~x ).

2. x |= x.

y and z are user-defined objects and the += operator is an overloaded member function. The operator is overloaded such that y += z adds z and y, then stores the result in y. Which of the following expressions is always equivalent to y += z? 1. y = y operator+= z 2. y.operator+=(z) 3. y = y + z 4. y operator+=(y + z)

2. y.operator+=(z)

Which of the following capabilities do "raw" C++ arrays not provide? 1. Dynamic size expansion to accommodate more elements. 2. Array comparison. 3. "Raw" arrays do not provide any of the above capabilities. 4. Subscript range checking.

3. "Raw" arrays do not provide any of the above capabilities.

Which of the following is not a bitwise operator? 1. ~. 2. ^. 3. *. 4. >>.

3. *.

Three of the following expressions have the same value. Which of the following expressions has a value different from the others'? 1. *&Ptr. 2. &*Ptr. 3. *Ptr. 4. Ptr.

3. *Ptr.

Given that k is an integer array starting at location 2000, kPtr is a pointer to k and each integer is stored in 4 bytes of memory, what location does kPtr + 3 point to? 1. 2003 2. 2006 3. 2012 4. 2024

3. 2012

An algorithm that requires ________ operations to complete its task on n data elements is said to have linear runtime. 1. n^3 + 9 2. 3 n^2 + 3 n + 2 3. 2n + 1 4. 6

3. 2n + 1

To follow the principle of least privilege, the selectionSort function should receive the array to be sorted as: 1. A nonconstant pointer to nonconstant data. 2. A constant pointer to constant data. 3. A constant pointer to nonconstant data. 4. A nonconstant pointer to constant data.

3. A constant pointer to nonconstant data.

If string s1 is lexicographically greater than string s2, then the value returned by s2.compare(0, s2.size(), s1) must be? 1. 0 2. -1 3. A negative number. 4. A positive number.

3. A negative number.

A function that modifies an array by using pointer arithmetic such as ++ptr to process every value should have a parameter that is: 1. A constant pointer to nonconstant data. 2. A nonconstant pointer to nonconstant data. 3. A nonconstant pointer to constant data. 4. A constant pointer to constant data.

3. A nonconstant pointer to constant data.

Function mismatch returns: 1. The position number where the two specified sequences do not match. 2. A pair containing the two elements in the specified sequences that do not match. 3. A pair containing two iterators pointing to the two locations in the specified sequences that do not match. 4. A bool indicating whether the two specified sequences do not match.

3. A pair containing two iterators pointing to the two locations in the specified sequences that do not match.

A pointer cannot be assigned to: 1. Another pointer of the same type without using the cast operator. 2. A pointer to void without using the cast operator. 3. A pointer of a type other than its own type and void without using the cast operator. 4. Any other pointer by using the cast operator.

3. A pointer of a type other than its own type and void without using the cast operator.

A Standard Library algorithm cannot: 1. Return an iterator. 2. Take two iterators as arguments to specify a range. 3. Access Standard Library members directly. 4. Be used with containers that support more powerful iterators than the minimum requirements for the algorithm.

3. Access Standard Library members directly.

Which of the following outputs does not guarantee that the uppercase flag has been set? 1. All hexadecimal numbers appear in the form 0X87. 2. All numbers written in scientific notation appear the form 6.45E+010. 3. All text outputs appear in the form SAMPLE OUTPUT. 4. All hexadecimal numbers appear in the form AF6.

3. All text outputs appear in the form SAMPLE OUTPUT.

Assuming the definition, class BasePlusCommissionEmployee : public CommissionEmployee which of the following is false? 1. The colon ( : ) in the header of the class definition indicates inheritance. 2. The keyword public indicates the type of inheritance. 3. All the public and protected members of class BasePlusCommissionEmployee are inherited as public and protected members, respectively, into class CommissionEmployee. 4. CommissionEmployee is the base class and BasePlusCommissionEmployee is the derived class.

3. All the public and protected members of class BasePlusCommissionEmployee are inherited as public and protected members, respectively, into class CommissionEmployee.

Assuming the definition, class Circle : public Point which of the following is false? 1. Point is the base class and Circle is the derived class. 2. The keyword public indicates the type of inheritance. 3. All the public and protected members of class Circle are inherited as public and protected members, respectively, into class Point. 4. The colon ( : ) in the header of the class definition indicates inheritance.

3. All the public and protected members of class Circle are inherited as public and protected members, respectively, into class Point.

Returning references to non-const, private data: 1. Allows private functions to be modified. 2. Is only dangerous if the binary scope resolution operator (::) is used in the function prototype. 3. Allows private member variables to be modified, thus "breaking encapsulation." 4. Results in a compiler error.

3. Allows private member variables to be modified, thus "breaking encapsulation."

Select the incorrect statement. Binary search trees (regardless of the order in which the values are inserted into the tree): 1. Always have multiple links per node. 2. Can be sorted efficiently. 3. Always have the same shape for a particular set of data. 4. Are nonlinear data structures.

3. Always have the same shape for a particular set of data.

The type of function a client would use to check the balance of a bank account would be: 1. A utility function. 2. A predicate function. 3. An access function. 4. A constructor.

3. An access function.

Linear search can be used on: 1. Sorted arrays. 2. Integer arrays. 3. Any of the above. 4. Unsorted arrays.

3. Any of the above.

Which of the following is not a dynamic data structure? 1. Linked list. 2. Stack. 3. Array. 4. Binary tree.

3. Array.

Structure variables may not be initialized by: 1. Array-like member initializer lists. 2. Assigning values to individual data members. 3. Assigning user-defined values in the struct definition. 4. Assigning the value of another structure variable of the same type.

3. Assigning user-defined values in the struct definition.

virtual functions must: 1. Be overridden in every derived class. 2. Be declared virtual in every derived class. 3. Be declared virtual in the base class. 4. Have the same implementation in every derived class.

3. Be declared virtual in the base class.

For operators overloaded as non-static member functions: 1. Binary operators can have two arguments and unary operators can have one. 2. Both binary and unary operators take one argument. 3. Binary operators can have one argument, and unary operators cannot have any. 4. Neither binary nor unary operators can have arguments.

3. 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? 1. ~( ~Bit2 ). 2. Bit1 & Bit2. 3. Bit1 ^ Bit2. 4. Bit1 | Bit2.

3. Bit1 ^ Bit2.

Variables defined inside a member function of a class have: 1. File scope. 2. Class scope. 3. Block scope. 4. Class or block scope, depending on whether the binary scope resolution operator (::) is used.

3. Block scope.

Pointers may be assigned to which of the following? 1. Any integer values. 2. An address. 3. Both (b) and (c). 4. NULL.

3. Both (b) and (c).

To prevent class objects from being copied: 1. Make the overloaded assignment operator private. 2. Make the copy constructor private. 3. Both Make the overloaded assignment operator private and Make the copy constructor private. 4. None of these.

3. Both Make the overloaded assignment operator private and Make the copy constructor private.

Which of the following is true? 1. Only class templates may specify default type arguments for type parameters. 2. Only function templates may specify default type arguments for type parameters. 3. Both class templates and function templates may specify default type arguments for type parameters. 4. None of these.

3. Both class templates and function templates may specify default type arguments for type parameters.

Which of the following is not true about setw and width? 1. If the width set is not sufficient the output prints as wide as it needs. 2. They are used to set the field width of output. 3. Both of them can perform two tasks, setting the field width and returning the current field width. 4. They only apply for the next insertion/extraction.

3. Both of them can perform two tasks, setting the field width and returning the current field width.

Sorting a preexisting sequence of n elements can be accomplished with the heapsort algorithm by: 1. Calling make_heap on the entire sequence and then calling pop_heap on the entire sequence n times. 2. Calling push_heap on the entire sequence n times and then calling pop_heap on the entire sequence n times. 3. Calling make_heap on the entire sequence and then calling sort_heap on the entire sequence. 4. Calling push_heap on the entire sequence n times and then calling sort_heap on the entire sequence.

3. Calling make_heap on the entire sequence and then calling sort_heap on the entire sequence.

Constant variables: 1. Can be assigned values in executable statements. 2. Do not have to be initialized when they are declared. 3. Can be used to specify array sizes, thereby making programs more scalable. 4. Can be used to specify array sizes, but this makes programs harder to understand.

3. Can be used to specify array sizes, thereby making programs more scalable.

The delete [] operator: 1. Can terminate the program. 2. Must be told which destructor to call when destroying an object. 3. Can delete an entire array of objects declared using new. 4. Is called implicitly at the end of a program.

3. Can delete an entire array of objects declared using new.

The total number of elements that can be stored in a string without increasing its current amount of allocated memory is called its: 1. Size. 2. Length. 3. Capacity. 4. Maximum size.

3. Capacity.

Which of the following is not true about separating a class's interface and implementation? 1. Inline member function definitions are included in the header file. 2. Private data members are included in the header file. 3. Changes in the class's implementation will affect the client. 4. Changes in the class's interface will affect the client.

3. Changes in the class's implementation will affect the client.

Many ___________ exist which help to develop programs from portable, carefully tested and widely available components. 1. Structured program environments. 2. Object libraries. 3. Class libraries. 4. Driver files.

3. Class libraries.

strtok does not: 1. Replace each delimiting character with '\0'. 2. Return a pointer to the token it creates. 3. Completely tokenize the string the first time it is called. 4. Modify the input string.

3. Completely tokenize the string the first time it is called.

Nontype parameters are: 1. Unable to have default arguments. 2. Specified before the angle-bracket-enclosed type-parameter list. 3. Constants. 4. Required for class templates.

3. Constants.

Which of the following prints the address of character string "string" given the following declaration? char * string = "test"; 1. cout << string; 2. cout << *&string; 3. cout << static_cast< void * >( string ); 4. cout << * string;

3. cout << static_cast< void * >( string );

Which of the following does not apply to an istringstream object? 1. Data is stored in the object as characters. 2. Input from the object works identically to input from any file stream. 3. Data in a string can be appended to it. 4. It is used to inputs data from a string in memory to program variables.

3. Data in a string can be appended to it.

Which of the following statements will not produce a syntax error? 1. Defining a const member function that modifies a data member of the object. 2. Invoking a non-const member function on a const object. 3. Declaring an object to be const. 4. Declaring a constructor to be const.

3. Declaring an object to be const.

________ is not an advantage of linked lists when compared to arrays. 1. Dynamic memory allocation. 2. Efficient insertion and deletion. 3. Direct access to any list element. 4. No need to allocate extra space, "just in case."

3. Direct access to any list element.

The algorithms in the Standard Library: 1. Use virtual function calls. 2. Are implemented as member functions of the container classes. 3. Do not depend on the implementation details of the containers on which they operate. 4. Are not as efficient as the algorithms presented in most textbooks.

3. Do not depend on the implementation details of the containers on which they operate.

The function call string1.erase( 5 ) will: 1. Return a copy of string1 minus the character that occupied position 5. 2. Erase all characters up to and including the character in position 5 from string1. 3. Erase all characters starting from and including the character in position 5 to the end of string1. 4. Return a copy of string1 minus every fifth character.

3. Erase all characters starting from and including the character in position 5 to the end of string1.

Strings represented as character arrays cannot: 1. Be initialized with initializer lists. 2. Be used with cout and cin. 3. Grow or shrink dynamically. 4. Be initialized using string literals.

3. Grow or shrink dynamically.

static data members of a certain class: 1. Cannot be changed, even by objects of the same that class. 2. Can be accessed only if an object of that class exists. 3. Have class scope. 4. Can only be changed by static member functions.

3. Have class scope.

Iterators do not: 1. Allow the characters to be modified. 2. Allow backward traversal of strings. 3. Have range checking. 4. Have syntax similar to pointer operations.

3. Have range checking.

The strtol and stroul functions do not: 1. Need a header file to be used. 2. Take three arguments. 3. Have the same return types. 4. Have the ability to return data in base 8.

3. Have the same return types.

Select the false statement. The functions set_terminate and set_unexpected: 1. Take as arguments pointers to void functions with no arguments. 2. Return pointers to the last function called by terminate and unexpected, respectively. 3. Have their prototypes in header file . 4. Each return 0 the first time they are called.

3. Have their prototypes in header file

Classes cannot: 1. Include objects from other classes as members. 2. Be used to model attributes and behaviors of objects. 3. Initialize data members in the class definition. 4. Be derived from other classes.

3. Initialize data members in the class definition.

Assuming the following is the beginning of the constructor definition for class Circle which inherits from class Point, Circle::Circle( double r, int a, int b ) : Point( a, b ) The second line: 1. Causes a compiler error. 2. Indicates inheritance. 3. Invokes the Point constructor with values a and b. 4. Is unnecessary because the Point constructor is called automatically.

3. Invokes the Point constructor with values a and b.

( *max )( num1, num2, num3 );: 1. Is the prototype for function max. 2. Is the header for function max. 3. Is a call to the function pointed to by max. 4. Is a declaration of a pointer to a function called max.

3. Is a call to the function pointed to by max.

A string array: 1. Can only provide access to strings of a certain length. 2. Is always less memory efficient than an equivalent double-subscripted array. 3. Is actually an array of pointers. 4. Stores an actual string in each of its elements.

3. Is actually an array of pointers.

Unlike a vector, a deque: 1. Provides efficient insertion and deletion only at its front. 2. Does not provide indexed access with the subscript operator. 3. Is not stored in contiguous memory. 4. Cannot store as many different data types.

3. Is not stored in contiguous memory.

An overloaded + operator takes a class object and a double as operands. For it to be commutative (i.e., a + b and b + a both work): 1. operator+ must be a member function of the class from which the objects are instantiated. 2. operator+ must be a non-member function. 3. It must be overloaded twice; the operator+ function that takes the object as the left operand must be a member function, and the other operator+ function must be a global function. 4. The + operator cannot be overloaded to be commutative.

3. It must be overloaded twice; the operator+ function that takes the object as the left operand must be a member function, and the other operator+ function must be a global function.

Which of the following is false? 1. To receive a list initializer as an argument to a constructor, you can declare the constructor's parameter as type list_initialier<T> where T represents the type of the values in the list initializer. 2. To receive a list initializer as an argument to a constructor, you can declare the constructor's parameter as type initializer_list<T> where T represents the type of the values in the list initializer. 3. It's not possible to pass a list initializer to a constructor. 4. Both To receive a list initializer as an argument to a constructor, you can declare the constructor's parameter as type list_initialier<T> where T represents the type of the values in the list initializer and It's not possible to pass a list initializer to a constructor.

3. It's not possible to pass a list initializer to a constructor

An array is not: 1. A consecutive group of memory locations. 2. Subscripted by integers. 3. Made up of different data types. 4. None of these.

3. Made up of different data types.

Downcasting enables: 1. A derived-class object to be treated as a base-class object. 2. A base-class object to be treated as a derived-class object. 3. Making a base-class pointer into a derived-class pointer. 4. Making a derived-class pointer into a base -class pointer.

3. Making a base-class pointer into a derived-class pointer.

When composition (one object having another object as a member) is used: 1. The host object is constructed first and then the member objects are placed into it. 2. Member objects are constructed first, in the order they appear in the host constructor's initializer list. 3. Member objects are constructed first, in the order they are declared in the host's class. 4. Member objects are destructed last, in the order they are declared in the host's class.

3. Member objects are constructed first, in the order they are declared in the host's class.

Which of the following represents the efficiency of the insertion sort? 1. O(1) 2. O(n) 3. O(n^2) 4. None of these.

3. O(n^2)

For a class template, the binary scope resolution operator (::) is needed: 1. In neither the definition nor prototype of member functions. 2. Both in the prototype and definition of a member function. 3. Only in the definitions of the member functions defined outside the class. 4. Only if multiple class-template specializations will be created from this class template.

3. Only in the definitions of the member functions defined outside the class.

Which of the following statements about polymorphism is false? 1. With polymorphism, you can direct a variety of objects to behave in manners appropriate to those objects without even knowing their types. 2. With polymorphism, new types of objects that can respond to existing messages can easily be incorporated into a system without modifying the base system. 3. Polymorphism enables you to deal in specifics and let the execution-time environment concern itself with the generalities. 4. To get polymorphic behavior among existing objects, those objects must be instantiated from classes in the same inheritance hierarchy.

3. Polymorphism enables you to deal in specifics and let the execution-time environment concern itself with the generalities.

Concrete classes that inherit virtual functions but do not override their implementations: 1. Have vtables which are the same as those of their base classes. 2. Receive their own copies of the virtual functions. 3. Receive pointers to their base classes' virtual functions. 4. Receive pointers to pure virtual functions.

3. Receive pointers to their base classes' virtual functions.

Member function definitions: 1. Always require the binary scope operator (::). 2. Can use the binary scope operator anywhere, but become public functions. 3. Require the binary scope operator only when being defined outside of the definition of their class. 4. Must use the binary scope operator in their function prototype.

3. Require the binary scope operator only when being defined outside of the definition of their class.

sizeof: 1. Is a binary operator. 2. Returns the total number of elements in an array. 3. Returns the total number of bytes in a variable. 4. Usually returns a double.

3. Returns the total number of bytes in a variable.

To reset the format state of the output stream: 1. Call the reset member function. 2. Call the flags member function with the ios_base::fmtflags constant as the argument. 3. Save a copy of the fmtflags value returned by calling member function flags before making any format changes, and then call flags again with that fmtflags value as the argument. 4. You must manually apply each individual format change member function or stream manipulator to restore the default format state.

3. Save a copy of the fmtflags value returned by calling member function flags before making any format changes, and then call flags again with that fmtflags value as the argument.

Both "ignoring the exception" and "aborting the program" are error-handling techniques that: 1. Allow program execution to proceed as if no error had occurred. 2. Cannot be used if the error is fatal. 3. Should not be used for mission-critical applications. 4. Always result in a resource leak.

3. Should not be used for mission-critical applications.

The prototypes of overloaded cast operator functions do not: 1. Specify the type they convert to. 2. Specify the type that is being converted. 3. Specify a return type. 4. Need to be defined inside the class whose objects are being converted.

3. Specify a return type.

An algorithm that could execute for an unknown amount of time because it depends on random numbers may: 1. Issue a compiler error. 2. Have a redundancy. 3. Suffer from indefinite postponement. 4. Get caught in an infinite loop.

3. Suffer from indefinite postponement.

Functions iter_swap and swap_ranges are similar in that both: 1. Swap a range of elements. 2. Take two arguments. 3. Take forward iterators as arguments. 4. Can only swap elements within the same array or container.

3. Take forward iterators as arguments.

The array subscript operator [], when overloaded, cannot: 1. Be used with linked list classes. 2. Take a float as an operand. 3. Take multiple values inside (e.g., [4,8]). 4. Take user-defined objects as operands.

3. Take multiple values inside (e.g., [4,8]).

Upon encountering the designated delimiter character, the ignore member function will: 1. Read it in and return its value. 2. Ignore it and continue reading and discarding characters. 3. Terminate. 4. Replace it with an EOF character.

3. Terminate.

The main difference between a pure virtual function and a virtual function is: 1. The return type. 2. The member access specifier. 3. That a pure virtual function cannot have an implementation. 4. The location in the class.

3. That a pure virtual function cannot have an implementation.

Which of the following is not an argument of the assign member function? 1. The start location. 2. The number of characters to copy. 3. The end location. 4. The string to copy.

3. The end location.

Which situation would require the operator to be overloaded as a non-member function? 1. The overloaded operator is =. 2. The left most operand must be a class object (or a reference to a class object). 3. The left operand is an int. 4. The operator returns a reference.

3. The left operand is an int.

Which of the following searches through a string object from right-to-left? 1. find 2. find_first_of 3. find_last_of 4. find_first_not_of

3. find_last_of

After the ith iteration of the selection sort: 1. None of the above. 2. The smallest i items of the array will be sorted into decreasing order in the first i elements of the array. 3. The smallest i items of the array will be sorted into increasing order in the first i elements of the array. 4. The largest i items of the array will be sorted into decreasing order in the last i elements of the array.

3. The smallest i items of the array will be sorted into increasing order in the first i elements of the array.

Which of the following is not true of a constructor and destructor of the same class? 1. They both have the same name aside from the tilde (~) character. 2. They are both usually called once per object created. 3. They both are able to have default arguments. 4. Both are called automatically, even if they are not explicitly defined in the class.

3. They both are able to have default arguments.

Which of the following is not true of pointers to functions? 1. They contain the starting address of the function code. 2. They can be stored in arrays. 3. They can not be assigned to other function pointers. 4. They are dereferenced in order to call the function.

3. They can not be assigned to other function pointers.

Which of the following statements about virtual functions is false? 1. They allow the program to select the correct implementation at execution time. 2. They can use either static or dynamic binding, depending on the handles on which the functions are called. 3. They do not remain virtual down the inheritance hierarchy. 4. They can be called using the dot operator.

3. They do not remain virtual down the inheritance hierarchy

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: 1. Only to the current value being displayed. 2. Only to outputs displayed in the current statement. 3. Until explicitly set to a different setting. 4. Until the output buffer is flushed.

3. Until explicitly set to a different setting.

When used with ofstream objects, operator! is not: 1. Overloaded. 2. Used to determine if the open operation succeeded. 3. Used to close a file explicitly. 4. Used to return a nonzero value if an error occurs.

3. Used to close a file explicitly.

Which of the following statements is true? 1. When opening a file, you can specify the name of the file only as a pointer-based string. 2. When opening a file, you can specify the name of the file only as a string object. 3. When opening a file, you can specify the name of the file as either a pointer-based string or a string object. 4. None of these.

3. When opening a file, you can specify the name of the file as either a pointer-based string or a string object.

When should base class members be declared protected? 1. When all clients should be able to access these members. 2. When these members are used only by member functions of this base class. 3. When these members should be available only to derived classes (and friends), but not to other clients. 4. The protected access specified should never be used.

3. When these members should be available only to derived classes (and friends), but not to other clients.

The merge sort algorithm: 1. Can be used only on vectors of even length. 2. Works by reducing vectors down to the base case of a two-element vector. 3. Works by merging two sorted vectors into one larger sorted vector. 4. Cannot be implemented recursively.

3. Works by merging two sorted vectors into one larger sorted vector.

Which statement about operator overloading is false? 1. Operator overloading is the process of enabling C++'s operators to work with class objects. 2. C++ overloads the addition operator (+) and the subtraction operator (-) to perform differently, depending on their context in integer, floating-point and pointer arithmetic with data of fundamental types. 3. You can overload all C++ operators to be used with class objects. 4. When you overload operators to be used with class objects, the compiler generates the appropriate code based on the types of the operands.

3. You can overload all C++ operators to be used with class objects.

Which bitset function could be used to create the logical not of a bitset object b? 1. b.set() 2. b.reset() 3. b.flip() 4. b.none()

3. b.flip()

A lambda function can capture local variables ________ and manipulate them inside the lambda's body. 1. by value. 2. by reference. 3. by value or by reference. 4. None of these.

3. by value or by reference.

Which of the following is false? 1. If a string is converted to a C-style array using data, modifying the string could cause the pointer previously returned by data to become invalid. 2. Converting a string containing one or more null characters to a C-style string can cause logic errors. 3. c_str returns a character array of the same length as the string object it is called on. 4. copy implicitly converts a string to a non-null terminated character array.

3. c_str returns a character array of the same length as the string object it is called on.

Which of the following is not true? 1. If a string is converted to a C-style array using data, modifying the string could cause the pointer previously returned by data to become invalid. 2. d. copy implicitly converts a string to a non-null terminated character array. 3. c_str returns a character array of the same length as the string object it is called on. 4. Converting a string containing one or more null characters to a C-style string can cause logic errors.

3. c_str returns a character array of the same length as the string object it is called on.

Which of the following is not an object of the ostream class? 1. cout 2. cerr 3. cin 4. clog

3. cin

Assume that the array named items contains the integer values 0, 2, 4, 6 and 8. Which of the following set of statements uses the range-based for loop to display each value in items? 1. for ( int i = 0; i < items.size(); ++i ) cout << items[ i ] << endl; 2. for ( int item : items ) cout << items[ item ] << endl; 3. for ( int item : items ) cout << item << endl; 4. for ( int item : i < items.size() ) cout << item << endl;

3. for ( int item : items ) cout << item << endl;

The proper syntax for a throw list is: 1. int g( double h ) throw ( a ) throw ( b ) throw ( c ). 2. int g( double h ) throw ( a ), throw ( b ), throw ( c ). 3. int g( double h ) throw ( a, b, c ).

3. int g( double h ) throw ( a, b, c ).

Which of the following stream manipulators causes an outputted number's sign to be left justified, its magnitude to be right justified and the center space to be filled with fill characters? 1. left 2. right 3. internal 4. showpos

3. internal

A class's functions can throw exceptions, such as ________ to indicate invalid data. 1. invalid_data 2. bad_data 3. invalid_argument 4. bad_argument

3. invalid_argument

The & operator can be applied to: 1. constants. 2. rvalues. 3. lvalues. 4. string literals.

3. lvalues.

Which of the following best describes the array name n in the declaration int n[10];? 1. n is a nonconstant pointer to nonconstant data. 2. n is a nonconstant pointer to constant data. 3. n is a constant pointer to nonconstant data. 4. n is a constant pointer to constant data.

3. n is a constant pointer to nonconstant data.

Which of the following is not an operator overloaded by the C++ language? 1. <<. 2. +. 3. pow. 4. >>.

3. pow.

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 ________? 1. protected, private 2. public, private 3. protected, protected 4. public, protected

3. protected, protected

Which of the following is not a member function of all sequence containers? 1. front 2. back 3. push_front 4. push_back

3. push_front

If string s1 has the value "computer" and string s2 has the value "promise", which call to insert will produce the string "compromise"? 1. s1.insert( 4, s2, 0, string::npos ); 2. s1.insert( string::npos, s2, 0, 4 ); 3. s2.insert( 0, s1, 0, 3 ); 4. s2.insert( 3, s1, 0, 3 );

3. s2.insert( 0, s1, 0, 3 );

Which of the following is not a difference between hex and setbase? 1. setbase is a parameterized stream manipulator and hex is not. 2. setbase is provided by a different header file than hex. 3. setbase(16) and hex have different effects on stream output. 4. setbase takes an argument but hex does not.

3. setbase(16) and hex have different effects on stream output.

Which of the following gives the number of elements in the array int r[ 10 ]? 1. sizeof r 2. sizeof ( *r ) 3. sizeof r / sizeof ( int ) 4. sizeof ( *r ) / sizeof ( int )

3. sizeof r / sizeof ( int )

Which of the following is not a kind of inheritance in C++? 1. public. 2. private. 3. static. 4. protected.

3. static.

Which of the following statements produces the same results as the statement: std::copy( v1.begin(), v1.end(), v2.begin() ); if v1 and v2 are both 10-element vectors? 1. std::copy_backward( v1.begin(), v1.end(), v2.begin() ); 2. std::copy_backward( v2.begin(), v2.end(), v1.begin() ); 3. std::copy_backward( v1.begin(), v1.end(), v2.end() ); 4. std::copy_backward( v2.begin(), v2.end(), v1.end() );

3. std::copy_backward( v1.begin(), v1.end(), v2.end() );

Which of the following is an invalid definition? 1. string sa = "computers"; 2. string sb( "computers" ); 3. string sc( 'c' ); 4. string sd( 9, 'c' );

3. string sc( 'c' );

Assuming that string1 = "hello" and string2 = "hello world", which of the following returns 0? 1. strcmp( string1, string2 ); 2. strcmp( string1, string2, 6 ); 3. strncmp( string1, string2, 5 ); 4. strncmp( string1, string2, 6 );

3. strncmp( string1, string2, 5 );

Which function would be the most useful for determining if a certain word is contained in a string representing a sentence? 1. strcspn 2. strchr 3. strstr 4. strrchr

3. strstr

Class string has member function ________ to interchange the data stored in two string objects. 1. exchange 2. switch 3. swap 4. copyto

3. swap

Which C++ data type was designed to store Unicode characters? 1. char 2. long 3. wchar_t 4. size_t

3. wchar_t

A merge sort operation runs in: 1. O(log n) time. 2. O(n) time. 3.O(n log n) time. 4. O(n^2) time.

3.O(n log n) time.

There exists a data type Date with member function Increment that increments the current Date object by one. The ++ operator is being overloaded to postincrement an object of type Date. Select the correct implementation: 1. Date Date::operator++( int ) { Date temp = *this; Increment(); return *temp; } 2. Date Date::operator++( int ) { Increment(); Date temp = *this; return temp; } 3. Date Date::operator++( int ) { Date temp = *this; return this; temp.Increment(); } 4. Date Date::operator++( int ) { Date temp = *this; Increment(); return temp; }

4. Date Date::operator++( int ) { Date temp = *this; Increment(); return temp; }

If string s contains "antidisestablishmentarianism", then s.substr( 7, 13 ) would be: 1. "establish" 2. "ishmenta" 3. "establi" 4. "establishment"

4. "establishment"

Which of the following preprocessor directives does not constitute part of the preprocessor wrapper? 1. #define 2. #endif 3. #ifndef 4. #include

4. #include

Which operator corresponds to operator keyword and_eq? 1. && 2. != 3. & 4. &=

4. &=

What method should be used to pass an array to a function that does not modify the array and only looks at it using array subscript notation: 1. A nonconstant pointer to nonconstant data. 2. A nonconstant pointer to constant data. 3. A constant pointer to nonconstant data. 4. A constant pointer to constant data.

4. A constant pointer to constant data.

Select the false statement. Depending on the compiler: 1. A failed new operation can return a 0. 2. A failed new operation can throw a bad_alloc exception. 3. A failed new operation can throw an exception if the <new> header file has been included. 4. A failed new operation can automatically be caught at compile time.

4. A failed new operation can automatically be caught at compile time.

catch blocks are not required to contain: 1. Braces { }. 2. Parentheses ( ). 3. Some form of parameter type indication. 4. A parameter name.

4. A parameter name.

Attributes of a heap do not include: 1. Having the largest element at the top of the heap. 2. Having a binary-tree structure. 3. The children of a given node are less than or equal to the parent node's value. 4. A preference to pop, rather than push, elements in the heap.

4. A preference to pop, rather than push, elements in the heap.

A message between two objects in a UML sequence diagram is represented by: 1. A dashed line with a filled arrowhead. 2. A solid line with a stick arrowhead. 3. A dashed line with a stick arrowhead. 4. A solid line with a filled arrowhead.

4. A solid line with a filled arrowhead.

Which of the following is not true? 1. The first element of an array is the zeroth. 2. The position number contained within square brackets is called a subscript. 3. The last element of an array has position number one less than the array size. 4. A subscript cannot be an expression.

4. A subscript cannot be an expression.

Which of the following tasks cannot be performed using a range-based for loop? 1. Calculating the product of all the values in an array. 2. Displaying all even element values in an array. 3. Incrementing the value stored in each element of the array. 4. Accessing the element's subscript.

4. Accessing the element's subscript

Structure variable declarations can be incorporated into a structure definition by placing a comma-separated list of variable names: 1. After struct StructureName and before the left brace. 2. After the left brace and before the member declarations. 3. After the member declarations and before the right brace. 4. After the right brace and before the semicolon.

4. After the right brace and before the semicolon.

Which of the following does not declare a 2-by-2 array and set all four of its elements to 0? 1. int b[ 2 ][ 2 ]; for ( int i = 0; i < 2; i++ ) for ( int j = 0; j < 2; j++ ) b[ i ][ j ] = 0;. 2. int b [ 2 ][ 2 ]; b[ 0 ][ 0 ] = b[ 0 ][ 1 ] = b[ 1 ][ 0] = b[ 1 ][ 1 ] = 0;. 3. int b[ 2 ][ 2 ] = { 0 };. 4. All of the above initialize all of their elements to 0.

4. All of the above initialize all of their elements to 0.

Class deque provides: 1. Efficient indexed access to its elements. 2. The ability to add storage at either end of the deque. 3. Efficient insertion and deletion operations at the front and back of a deque. 4. All of these.

4. All of these

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? 1. Errors are prone to be spread around. 2. It is time consuming. 3. It forces the system to store many physical copies of the code, creating a code-maintenance nightmare. 4. All of these are disadvantages of the "copy-and-paste" approach.

4. All of these 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? 1. It must overload the parentheses operator. 2. It can have data members. 3. It must be a concrete class. 4. All of these are true about a class that will be used to instantiate function objects.

4. All of these are true about a class that will be used to instantiate function objects.

Which of the following is not a valid runtime description according to Big O notation? 1. O(1) 2. O(n) 3. O(n^2) 4. All of these are valid.

4. All of these are valid.

Which of the following does not have a stream associated with it? 1. cerr. 2. cin. 3. cout. 4. All of these have streams associated with them.

4. All of these have streams associated with them.

Exception handling may allow a program to: 1. Terminate in a controlled manner. 2. Be more robust and fault-tolerant. 3. Continue executing as if no problem was encountered. 4. All of these.

4. All of these.

string iterators: 1. Must be dereferenced in order to access the character at each location. 2. Are not range checked. 3. Come in const and non-const forms. 4. All of these.

4. All of these.

Select the incorrect statement. Binary trees (regardless of the order in which the values are inserted into the tree): 1. Can be sorted efficiently. 2. Always have multiple links per node. 3. Are nonlinear data structures. 4. Always have the same shape for a particular set of data.

4. Always have the same shape for a particular set of data.

An error occurs if: 1. A non-reference, non-const, primitive data member is initialized in the member initialization list. 2. An object data member is not initialized in the member initialization list. 3. An object data member does not have a default constructor. 4. An object data member is not initialized in the member initialization list and does not have a default constructor.

4. An object data member is not initialized in the member initialization list and does not have a default constructor.

Friendship cannot be declared between a class template and: 1. A member function of another class. 2. A global function. 3. A class-template specialization. 4. Another class template.

4. Another class template.

Abstract classes: 1. Contain at most one pure virtual function. 2. Can have objects instantiated from them if the proper permissions are set. 3. Cannot have abstract derived classes. 4. Are defined, but the programmer never intends to instantiate any objects from them.

4. Are defined, but the programmer never intends to instantiate any objects from them.

Default type parameters are allowed only: 1. If the class template also has nontype parameters. 2. If the class template does not have any nontype parameters. 3. If the class is used as a container class. 4. As the rightmost (trailing) parameters in a template's type-parameter list.

4. As the rightmost (trailing) parameters in a template's type-parameter list.

The list sequence container does not: 1. Efficiently implement insert and delete operations anywhere in the list. 2. Use a doubly linked list. 3. Support bidirectional iterators. 4. Automatically sort inserted items.

4. Automatically sort inserted items.

What is the order in which their constructors and destructors will be called when an object of class A is instantiated and then destroyed? 1. A constructor, B constructor, B destructor, A destructor. 2. B constructor, A constructor, B destructor, A destructor. 3. A constructor, B constructor, A destructor, B destructor. 4. B constructor, A constructor, A destructor, B destructor.

4. B constructor, A constructor, A destructor, B destructor.

Select the false statement regarding inheritance. 1. A derived class can contain more attributes and behaviors than its base class. 2. A derived class can be the base class for other derived classes. 3. Some derived classes can have multiple base classes. 4. Base classes are usually more specific than derived classes.

4. Base classes are usually more specific than derived classes.

Which of the following is not true about searching algorithms and their efficiency? 1. A more efficient searching algorithm is usually more complex and difficult to implement. 2. The effort required to perform a search or a sort is particularly dependent on the number of data elements. 3. The major difference between various searching algorithms is the amount of effort they require to complete the search. 4. Big O notation is one way to describe how likely it is that a searching algorithm will find its target.

4. Big O notation is one way to describe how likely it is that a searching algorithm will find its target.

Pointers may be assigned which of the following values? 1. Any integer values. 2. An address. 3. nullptr. 4. Both An address and nullptr.

4. Both An address and nullptr.

A default constructor: 1. Is a constructor that must receive no arguments. 2. Is the constructor generated by the compiler when no constructor is provided by the programmer. 3. Does not perform any initialization. 4. Both Is a constructor that must receive no arguments and Is the constructor generated by the compiler when no constructor is provided by the programmer..

4. Both Is a constructor that must receive no arguments and Is the constructor generated by the compiler when no constructor is provided by the programmer..

Which of the following statements is not true about C++ input/output (I/O) features? 1. C++ allows users to specify I/O for their own data types. 2. C++ automatically calls the correct I/O operations for standard types. 3. C++ has some object-oriented I/O features. 4. C++ borrowed its type safe I/O capabilities from C.

4. C++ borrowed its type safe I/O capabilities from C.

Which of the following is false? 1. An entire non-char array cannot be input or output at once. 2. Arrays cannot be assigned to one another (i.e., array1 = array2;). 3. Two arrays cannot be meaningfully compared with equality or relational operators. 4. C++ ensures that you cannot "walk off" either end of an array.

4. C++ ensures that you cannot "walk off" either end of an array.

The delete operator: 1. Is called implicitly at the end of a program. 2. Must be told which destructor to call when destroying an object. 3. Can terminate the program. 4. Can delete an entire array of objects declared using new.

4. Can delete an entire array of objects declared using new.

The expression std::multimap< int, double, std::less< int > >::value_type( 15, 2.7 ): 1. Creates an empty multimap object. 2. Creates a multimap object containing one key/value pair. 3. Returns the number of times the key/value pair ( 15, 2.7 ) appears in the multimap. 4. Creates a pair object in which first is 15 (type int) and second is 2.7 (type double).

4. Creates a pair object in which first is 15 (type int) and second is 2.7 (type double).

To prevent class objects from being copied or assigned, you can: 1. Declare as private the class's copy constructor and overloaded assignment operator. 2. Declare the class's copy constructor and overloaded assignment operator with with = delete after the parameter list. 3. Simply do not declare a copy constructor or assignment operator in the class. 4. 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.

4. 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.

All of the following could cause a fatal execution-time error except: 1. Dereferencing a null pointer. 2. Dereferencing a pointer that has not been assigned to point to a specific address. 3. Dereferencing a pointer that has not been initialized properly. 4. Dereferencing a variable that is not a pointer.

4. Dereferencing a variable that is not a pointer.

dynamic_cast is often used to: 1. Perform type checking for objects. 2. Convert pointers to strings. 3. Upcast pointers. 4. Downcast pointers.

4. Downcast pointers.

A difference between function-template specializations and overloaded functions is that: 1. Function-template specializations cannot accept user-defined types. 2. Function-template specializations do not perform identical operations on each data type. 3. Overloaded functions usually do not perform similar operations on each data type. 4. Function-template specializations are generated by the compiler, not the programmer.

4. Function-template specializations are generated by the compiler, not the programmer.

Select the false statement. Container adapters: 1. Do not provide the actual data structure implementation for elements to be stored. 2. Have their data stored by underlying data structures. 3. Can push and pop elements. 4. Have limited iterator support.

4. Have limited iterator support.

The main difference between set and multiset is: 1. Their interface. 2. That one deals with keys only, and the other deals with key/value pairs. 3. Their efficiency. 4. How they handle duplicate keys.

4. How they handle duplicate keys.

The advantages of using typedef do not include: 1. Making programs more portable by allowing data types to be easily changed to meet system specifications. 2. Making type names shorter. 3. Making programs more readable. 4. Increasing the efficiency of accessing struct member variables.

4. Increasing the efficiency of accessing struct member variables.

Placing throw() after a function's parameter list: 1. Guarantees that only programmer-defined exceptions can be thrown in this function. 2. Indicates that the compiler will issue an error if the function contains a throw expression. 3. Guarantees that all exceptions can be thrown in this function. 4. Indicates that throwing an exception in this function would call unexpected.

4. Indicates that throwing an exception in this function would call unexpected.

The order of the arguments passed to function replace_copy_if must be: 1. OutputIterator, InputIterator, ReplacementValue, PredicateFunction. 2. InputIterator, OutputIterator, PredicateFunction, ReplacementValue. 3. OutputIterator, InputIterator, InputIterator, ReplacementValue, PredicateFunction. 4. InputIterator, InputIterator, OutputIterator, PredicateFunction, ReplacementValue.

4. InputIterator, InputIterator, OutputIterator, PredicateFunction, ReplacementValue.

Which of the following is false about the new operator and the object for which it allocates memory? 1. It calls the object's constructor. 2. It returns a pointer. 3. It does not require the size of the object to be explicitly specified in the new expression. 4. It automatically destroys the object after main is exited.

4. It automatically destroys the object after main is exited.

Which of the following is not true of a destructor? 1. It performs termination housekeeping. 2. It is called before the system reclaims the object's memory. 3. If the programmer does not explicitly provide a destructor, the compiler creates an "empty" destructor. 4. It releases the object's memory.

4. It releases the object's memory.

To use an operator on user-defined class objects, operator overloading: 1. Must never be used, with three exceptions. 2. Must never be used. 3. Must always be used. 4. Must always be used, with three exceptions.

4. Must always be used, with three exceptions.

Select the false statement. A rethrown exception: 1. Is detected by the next enclosing try block. 2. Is the immediate result of a throw command. 3. Can be processed by exception handlers following the enclosing try block. 4. Must have been fully processed at the time it was rethrown.

4. Must have been fully processed at the time it was rethrown.

An explicit constructor: 1. Cannot be called outside of the class it is declared in. 2. Can be implicitly called by the compiler to perform a data type conversion. 3. Does not initialize its class's data members. 4. Must take exactly one argument.

4. Must take exactly one argument.

Select the false statement. Outputs are: 1. Flushed automatically at the end of a program. 2. Flushed when the buffer fills. 3. Able to be synchronized with inputs. 4. Never automatically tied to inputs.

4. Never automatically tied to inputs.

Problems using switch logic to deal with many objects of different types do not include: 1. Forgetting to include an object in one of the cases. 2. Having to update the switch statement whenever a new type of object is added. 3. Having to track down every switch statement to do an update of object types. 4. Not being able to implement separate functions on different objects.

4. Not being able to implement separate functions on different objects

Which of the following is false? 1. static data members of both template and non-template classes are initialized at file scope. 2. With a non-template class, one copy of a static data member is shared among all objects created from that class. 3. Each class-template specialization created from a class template has its own copy of each static data member. 4. One copy of each static member function is shared between all class-template specializations in the class template.

4. One copy of each static member function is shared between all class-template specializations in the class template.

Which forms of inheritance are is-a relationships? 1. All forms of inheritance are is-a relationships. 2. Only public and private. 3. Only public and protected. 4. Only public.

4. Only public.

Which of the following is not a disadvantage of trying to modify a sequential access file? 1. Modifying data can potentially destroy other data. 2. It may be necessary to rewrite every record in the file to make a slight change. 3. Things that are stored in the same number of "raw data" bytes internally may not take up the same amount of space in a file. 4. Overwriting a record with another record of the same size is very difficult.

4. Overwriting a record with another record of the same size is very difficult.

Consider the following function: void reverse ( char string1, const char string2 ) { int stringsize = sizeof ( string1 ) / sizeof (char ); *( string1 + stringsize - 1 ) = '\0'; string1 = string1 + stringsize - 2; for ( ; *string2 != '\0' ; string1--, string2++ ) string1 = string2; } What method does the function use to refer to array elements? 1. Array subscript notation. 2. Pointer/offset notation where the pointer is actually the name of the array. 3. Pointer subscript notation. 4. Pointer/offset notation.

4. Pointer/offset notation.

Which of the following is not a key component of the Standard Library? 1. Containers. 2. Iterators. 3. Algorithms. 4. Pointers.

4. Pointers.

Which of the following is not a good example of a hierarchy likely to be modeled by inheritance? 1. Airplanes. 2. Geometric shapes. 3. Animals. 4. Prime numbers.

4. Prime numbers

Select the correct statement regarding C++ I/O streams: 1. C++ provides only high-level I/O capabilities because it is a high-level programming language. 2. High-level (formatted) I/O is best for large-volume transfers. 3. Low-level I/O breaks information down into small, meaningful groups of related bytes. 4. Programmers generally prefer high-level I/O to low-level I/O.

4. Programmers generally prefer high-level I/O to low-level I/O

Pointers cannot be used to: 1. Pass an argument by reference. 2. Manipulate dynamic data structures. 3. Contain memory addresses. 4. Reference values directly.

4. Reference values directly.

Which of the following is not a disadvantage of default memberwise copy with objects containing pointers? 1. Having the possibility of leaving a dangling pointer. 2. Allowing both objects to point to the same dynamically allocated storage. 3. Allowing the destructor of one object to be called while leaving the second pointer, to the same memory location, intact. 4. Requiring the explicit overloading of the assignment operator.

4. Requiring the explicit overloading of the assignment operator.

Two structure variables of the same type with the same member values, when compared will: 1. Always compare equally. 2. Never compare equally. 3. Sometimes compare equally. 4. Result in a compile error.

4. Result in a compile error.

sizeof: 1. Is a binary operator. 2. Returns the total number of elements in an array. 3. Usually returns a double. 4. Returns the total number of bytes in a variable.

4. Returns the total number of bytes in a variable.

Which of the following tasks would a binary search tree not be well suited for? 1. Duplicate elimination. 2. Searching. 3. Sorting. 4. Reversing an unsorted sequence.

4. Reversing an unsorted sequence.

Assuming that string1 = "hello" and string2 = "hello world", which of the following returns 0? 1. strncmp( string1, string2, 6 );. 2. strcmp( string1, string2, 6 );. 3. strcmp( string1, string2 );. 4. Strncmp( string1, string2, 5 );.

4. Strncmp( string1, string2, 5 );.

Associations in a class diagram that have no navigability arrows at all indicate: 1. That operations performed by this association do not return values. 2. That the two classes are the same. 3. Inheritance from the same base class. 4. That navigation can proceed in either direction across the association.

4. That navigation can proceed in either direction across the association.

To implicitly overload the += operator: 1. Only the + operator needs to be overloaded. 2. Only the = operator needs to be overloaded. 3. Both the + and = operators need to be overloaded. 4. The += operator cannot be overloaded implicitly.

4. The += operator cannot be overloaded implicitly.

Which statement about insertion sort is true? 1. A maximum of n comparisons are needed to sort the array, where n is the number of elements. 2. No temporary variables are needed. 3. Performance is maximized. 4. The algorithm is very simple compared to other sorting procedures.

4. The algorithm is very simple compared to other sorting procedures.

o prevent modification of array values passed to a function: 1. The array parameter can be preceded by the const qualifier. 2. A copy of the array must be made inside the function. 3. The array must be passed by reference.

4. The array must be declared static in the function.

Which of the following is a difference between the read and write functions? 1. One performs formatted I/O and the other does not. 2. They take different types of parameters. 3. write and gcount are member functions of the same class, whereas read is not. 4. The failbit is set only with read.

4. The failbit is set only with read.

Because the postfix increment operator returns objects by value and the prefix increment operator returns objects by reference: 1. Prefix increment has slightly more overhead than postfix increment. 2. The postfix increment operator returns the actual incremented object with its new value. 3. Objects returned by postfix increment cannot be used in larger expressions. 4. The postfix increment operator typically returns a temporary object that contains the original value of the object before the increment occurred.

4. The postfix increment operator typically returns a temporary object that contains the original value of the object before the increment occurred.

Select the false statement. The new operator: 1. Can attempt to allocate as much memory as the programmer requests. 2. Returns a pointer to a location in memory. 3. Can indicate failure differently on different compilers. 4. Throws a bad_alloc exception regardless of what function is registered with set_new_handler.

4. Throws a bad_alloc exception regardless of what function is registered with set_new_handler.

Assuming that all four of the following functions are defined, which one will be called by the function call square( 23.4 )? 1. template< typename T > T square( T num ) template< typename T1, typename T2 > 2. T1 square( T1 num1, T2 num2 ) 3. int square( int num ) 4. double square( double num )

4. double square( double num )

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. 1. fileObject.seekg( 2 ); 2. fileObject.seekg( 1, ios::cur ); 3. fileObject.seekg( 2, ios::beg ); 4. fileObject.seekg( 8, ios::end );

4. fileObject.seekg( 8, ios::end );

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? 1. eat 2. sleep 3. move 4. flapWings

4. flapWings

Which of the following is not a type of container (collection) class? 1. Arrays. 2. Stacks. 3. Linked lists. 4. floats.

4. floats.

The isxdigit function would return false on: 1. a 2. A 3. 2 4. g

4. g

Untying an input stream, inputStream, from an output stream, outputStream, is done with the function call: 1. inputStream.untie(). 2. inputStream.untie( &outputStream ). 3. inputStream.tie(). 4. inputStream.tie( 0 ).

4. inputStream.tie( 0 ).

Which statement would be used to declare a 10-element integer array c? 1. int array c[ 10 ];. 2. array c = int[ 10 ];. 3. c = int[ 10 ];. 4. int c[ 10 ];.

4. int c[ 10 ];.

Which of the following is not true about files? 1. C++ views each file as a sequential stream of bytes. 2. Files are opened by creating objects of stream classes. 3. Member functions of stream objects can be applied to file streams. 4. istream, ostream and iostream are derived from ifstream, ofstream and fstream, respectively.

4. istream, ostream and iostream are derived from ifstream, ofstream and fstream, respectively.

The ________ function allows characters of one part of a string to be copied into another, overlapping part of the same string. 1. memchr 2. memcmp 3. memcpy 4. memmove

4. memmove

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? 1. invalid_argument 2. bad_exception 3. out_of_range 4. overflow_error

4. overflow_error

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? 1. remove 2. remove_copy 3. remove_if 4. remove_copy_if

4. remove_copy_if

Which function changes the actual string stored in the string object (i.e., is not a const member function)? 1. length 2. empty 3. capacity 4. resize

4. resize

Which of the following would not return string::npos when used on the string s which contains "rack": 1. s.find_first_not_of( "crackling" ); 2. s.find_first_not_of( "packrat" ); 3. s.rfind( "car" ); 4. s.find( "ack" );

4. s.find( "ack" );

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. 1. set_intersection 2. set_difference 3. set_union 4. set_symmetric_difference

4. set_symmetric_difference

Which of the following function calls would not return the value that is its first argument? 1. std::min( 3, 23 ) 2. std::min( 'N', 'P' ) 3. std::max( 17, 16 ) 4. std::max( 'd', 'k' )

4. 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"? 1. strncpy( string1, string2, 6 );. 2. strcpy( string1, string2, 6 );. 3. Strncpy( string1, string2, 5 );. 4. strcpy( string1, string2 );.

4. strcpy( string1, string2 );.

The correct order in which an exception is detected and handled is: 1. try, catch, throw 2. throw, catch, try 3. catch, throw, try 4. try, throw, catch

4. try, throw, catch

If you add the following nodes to a binary search tree in the order they appear (left-to-right): 6 34 17 19 16 10 23 3 what will be the output of a postorder traversal of the resulting tree? A. 6 3 34 17 16 10 19 23. B. 3 6 17 16 10 19 23 34. C. 3 10 16 23 19 17 34 6. D. 10 16 23 19 17 34 3 6.

C. 3 10 16 23 19 17 34 6.

Which of the following are true about an abstract data type? I. Captures a data representation. II. Defines the operations that are allowed on its data. III. Replaces structured programming. A. II and III. B. I, II and III. C. I and II. D. I and III.

C. I and II.

Assuming the following constructor is provided for class Time explicit Time( int = 0, int = 0, int = 0 ); which of the following is not a valid way to initialize a Time object? 1. Time t1; 2. Time t2{ 22, 40 }; 3. Time t3( 22, 40 ); 4. Time t1; , Time t2{ 22, 40 }; and Time t3( 22, 40 ); are all valid ways to initialize a Time object.

Time t1; , Time t2{ 22, 40 }; and Time t3( 22, 40 ); are all valid ways to initialize a Time object.

The easiest way to set all the values of a vector to zero is to use function: 1. fill 2. fill_n 3. generate 4. generate_n

fill


Conjuntos de estudio relacionados

Assignment 6 - Uncovering Operational Risks

View Set

Earth Science -- Chapter 1 Review

View Set

Comprehensive Practice B W/Rationales 🥶

View Set