ULTIMATE CSIS 112 FINAL EXAM STUDY GUIDE

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

How many times will the following loop print hello? i=1 while (i <= 10) cout << "hello";

An infinite number of times

How many times will the following loop print hello? i = 1; while ( i <= 10 ) cout << "hello";

An infinite number of times.

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.

Assume that the function call operator() is overloaded for data type String in the usual sense of selecting a substring from a larger string. For a String object string1 with the character string "ABCDEFGHI", what string does string1(4, 2) return?

"EF"

Assuming that t is an array and tPtr is a pointer to that array, which expression refers to the address of element 3 of the array?

&t[3]

In what order would the following operators be evaluated? -,*,/,+,%

* , / , % , - , +

Three of the following expressions have the same value. Which of the following expressions has a value different from the others'?

*ptr

Inside a function definition for a member function of an object with data member x, which of the following is not equivalent to this->x:

*this.x

A header file is typically given the filename extension:

.h

memcmp would return ________ for the call memcmp("Hi, how are you?", "Hi, how are things?" , 6)

0

Consider the following code, assuming that x is an int with an initial value of 12 if( x = 6 ) cout << x; What is the output? 1. 6. 2. A syntax error is produced. 3. 12. 4. Nothing.

1. 6. Didn't use == but used assignment.

________ 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

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.

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.

A function prototype does not have to: 1. Include parameter names. 2. Terminate with a semicolon. 3. Match with all calls to the function. 4. Agree with the function definition.

1. Include parameter names.

An activity diagram for modeling the actions involved in executing a balance inquiry transaction using the BalanceInquiry object should not include: 1. Receiving the user's main menu input indicating a desire to inquire the amount of his or her balance. 2. Displaying the user's balance information on the screen. 3. Retrieving the user's balance information from the database of accounts. 4. All of the above actions should be modeled in this activity diagram.

1. Receiving the user's main menu input indicating a desire to inquire the amount of his or her balance.

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

1. The array parameter can be preceded by the const qualifier.

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

1. []

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

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

1. int or unsigned

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

1. ints

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

1. xor

What will be output by the following statement? cout << showpoint << setprecision(4) << 11.0 << endl;

11.00

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

2. ++.

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.

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

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 is not a sequence container provided by the Standard Library? 1. vector 2. array 3. list 4. deque

2. array

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 bitset member functions cannot be called with an empty argument list? 1. reset 2. test 3. size 4. none

2. test

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

( *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.

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.

Enumeration constants: 1. Must have unique integer values. 2. Can be assigned other values once they've been defined. 3. Must have unique identifiers. 4. Are declared using the keyword const.

3. Must have unique identifiers.

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.

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.

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()

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 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() );

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 );

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; }

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 C++ Standard Library headers does not contain a C++ Standard Library container class? 1. <vector>. 2. <list>. 3. <stack>. 4. <string>.

4. <string>.

Which of the following operators can be overloaded as a non-member function? 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.

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.

Which of the following does counter-controlled repetition require? 1. An initial value. 2. A condition that tests for the final value. 3. An increment or decrement by which the control variable is modified each time through the loop. 4. All of these.

4. All of these.

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.

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.

All math library functions: 1. Return data type int. 2. Must be called by preceding the function name by cmath::. 3. Can only be called after creating a math object. 4. Are global functions.

4. Are global functions.

float and double variables should be used: 1. To perform monetary calculations. 2. As counters. 3. To store true/false values. 4. As approximate representations of decimal numbers.

4. As approximate representations of decimal numbers.

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.

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.

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.

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.

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.

An example of a unary operator is: 1. The < relational operator. 2. The = assignment operator. 3. The % arithmetic operator. 4. The ! logical operator.

4. The ! logical operator.

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' };.

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

4. floats.

Assuming the following pseudocode for the Fibonacci series, what is the value of the 5th Fibonacci number (fibonacci (5))? fibonacci(0) = 0 fibonacci(1) = 1 fibonacci(n) = fibonacci(n - 1) + fibonacci(n - 2)

5

Given the following function template template <typename T> T maximum(T value1, T value2) { if (value1 > value2) { return value1; } else { return value2; } } what would be returned by the following two function calls? maximum(2, 5); maximum(2.3, 5.2);

5 and 5.2

Given the following function template Template < class T > T maximum ( T value1, T value2 ) { If ( value1 > value2 ) Return value1; Else Return value2; } What would be returned by the following two function calls? Maximum ( 2, 5); Maximum ( 2.3, 5.2 );

5 and 5.2

C++11's unsigned long long int type (which can be abbreviated as unsigned long long) enables you to store values in at least ________, which can hold numbers as large as 18,446,744,073,709,551,615.

8 bytes (64 bits)

When a member function is defined outside the class definition, the function header must include the class name and the ________________, followed by the function name to "tie" the member function to the class definition.

:: scope resolution operator

Which of the following C++ Standard Library header files does not contain a C++ Standard Library container class?

<string>

The assignment operator __ assigns the value of the expression on its right to the variable on its left.

=

[C++11] In C++11, you can tell the compiler to explicitly generate the default version of a default constructor, copy constructor, move constructor, copy assignment operator, move assignment operator or destructor by following the special member function's prototype with ________.

= default

Each of the following is a relational or equality operator except:

=!

Which of the following operators can be overloaded as a non-member function?

==

Which statement is false?

A class is an instance of its object.

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:

A constant pointer to constant data

To follow the principle of least privilege, the selectionSort function should receive the array to be sorted as:

A constant pointer to nonconstant data

A function prototype can always be omitted when:

A function is defined before it's first invoked

An activation record will be popped off the function call stack whenever:

A function returns control to its caller

An activation record will be popped off the function call stack whenever:

A function returns control to its caller.

A function that prints a string by using pointer arithmetic such as ++ptr to output each character should have a parameter that is:

A nonconstant pointer to constant data.

A function that modifies an array by using pointer arithmetic such as ++ptr to process every value of the array should have a parameter that is:

A nonconstant pointer to nonconstant data

A function that modifies an array by using pointer arithmetic such as ++ptr to process every value of the array should have a parameter that is:

A nonconstant pointer to nonconstant data.

Which of the following is false?

A subscript cannot be an expression.

Which of the following is not true of class template vector?

A vector can store only data of type int.

Which of the following statements is false?

Access specifiers are always followed by a semicolon (;).

Which of the following tasks cannot be performed using a range-based for loop?

Accessing the element's subscript

___is a set of methodologies that try to get software implemented quickly with fewer resources than previous methodologies. Design patterns. Agile software development. None of these. Refactoring.

Agile software development.

______ helps internet-based applications perform lie desktop applications

Ajax

___________ helps Internet-based applications perform like desktop applications.

Ajax

A switch statement should be used:

All of the above

[C++11]: 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?

All of the above are all valid ways to initialize a Time object.

Which of the following is not one of the disadvantages of using the "copy-and-paste" approach to duplicating code from one class into another class?

All of the above are disadvantages of the "copy-and-paste" approach.

Which of the following does not declare a 2-by-2 array and set all four of its elements to 0?

All of the above initialize all four of the array elements to 0

Which of the following does not declare a 2-by-2 array and set all four of its elements to 0?

All of the above initialize all four of the array elements to 0.

Which of the following statements about regular expressions is true?

All of the above statements are true.

Which of the following data types can be used to represent integers?

All of the above.

Which of the following is a compilation error?

All of the above.

Which of the following is a compilation error?

All of these

Which of the following is/are considered part of Web 2.0?

All of these

Which of the following is/are considered part of Web 2.0? Social networking. Collective intelligence. Community-generated content. All of these.

All of these

The type of function a client would use to check the balance of a bank account would be:

An access function

The type of function a client would use to check the balance of a bank account would be:

An access function.

17.3 Q2: In order to perform file processing in C++, which header files must be included?

Answer: (blank)

17.4 Q3: When used with ofstream objects, operator! is not:

Answer: Used to close a file explicitly.

Utility functions:

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

What is the name of the values the method call passes to the method for the parameters?

Arguments

A switch statement should be used:

As a multiple-selection structure.

float and double variables should be used:

As approximate representations of decimal numbers

Which of the following selection is free of syntax error?

Assume the following prototype is declared in Time class : void setTime(int, int, int);

Size, shape, color, weight, height and number of doors are all good examples of ___ . attributes operations objects behaviors

Attributes

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.

When an object of a derived class is instantiated, the __________ constructor initializes the _________ members.

Base class , base class

When an object of a derived class is instantiated, the __________ constructor initializes the _________ members.

Base class, base class.

Select the false statement regarding inheritance.

Base classes are usually more specific than derived classes.

Variables defined inside a member function of a class have:

Block scope.

A reference parameter:

Both (a) and (b)

To prevent class objects from being copied:

Both (a) and (b)

In the worst case for linear search, every element must be checked to determine whether the search element exists. When does this occur?

Both (a) and (c) above

A default constructor:

Both first and second choice.

A reference parameter:

Both first and second choice.

To prevent class objects from being copied:

Both first and second choice.

Which statement about exception handling is false?

Bounds checking is performed at execution time with vector member function at, and if a subscript is within the bounds of the array, the member function throws an out_of_bounds exception.

To execute multiple statements when an if statement's condition is true, enclose those statements in a pair of:

Braces, { }.

Which of the following statements is false?

Businesses using cloud computing services must still manage the applications, which can be costly.

Using the following function definition, the parameter list is represented by: A B (C) { D }

C

Using the following function definition, the parameter list represented by: A B ( C ) { D }

C

__________ initially became widely known as the development language of the UNIX operating system.

C

Which of the following statements about the C programming language is false?

C initially became widely known as the Windows operating system's development language.

Today, virtually all new major operating systems are written in: C or C++. Java. B or BCPL. C#.

C or C++

Today, virtually all new major operating systems are written in:

C or C++.

Which language was developed expressly for the .NET platform? Visual C++ Basic Visual Basic C#

C#

Which of the following is false?

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

[C++11]: Which of the following is true?

C++11 allows you to provide a default value for a data member when you declare it in the class declaration.

Which of the following is false?

C++11's long long type supports values in the range -2,147,483,647 to 2,147,483,647 as a minimum.

Which of the following statements is false? A.A cloud computing allows you to use software, hardware and information stored on remote computers via the internet and available on demand rather than having it stored on your personal computer B.Electronic health records enable health care providers to share patients information across a secure network, improving patient care, reducing the probability of error and increasing the overall efficiency of the health care system. C.Global Positioning System(GPS) devices a signal satellite to retrieve location-based information D.The Human Genome Project was founded to identify and analyze the 20,000+ genes in human DNA

C.

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

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 false?

C. Businessed using cloud which can be costly(fix later)

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.

Which of the following languages was designed for precise, efficient manipulation of large amounts of data? Basic. Fortran. Pascal. COBOL.

COBOL

If a member function of a class already provides all or part of the functionality required by a constructor or another member function then:

Call that member function from this constructor or member function.

Constant variables:

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

Conversion constructors:

Can convert between user-defined types.

The delete [] operator:

Can delete an entire array of objects declared using new.

Which of the following is correct when labeling cases in a switch structure?

Case 1

If the line: friend class A; appears in class B, and the line: friend class B; appears in class C, then:

Class A can access private variables of class B.

A string array is commonly used for:

Command-line arguments.

The ___ creates object code and stores it on disk. Preprocessor. Interpreter. Compiler. Loader.

Compiler

The ___________ creates object code and stores it on disk.

Compiler

This creates object code and stores it on disk

Compiler

Which of the following statements is false (assume we're referring to class Time)?

Compilers and IDEs typically doesn't invoke the linker for you after compiling your code.

Which of the following statements is true?

Compilers translate high-level language programs into machine language programs

Computers process data under control of sets of instructions called ___ . Computer programs. The operating system. Computer programmers. None of these.

Computer programs

Which of the following is false?

Continue and break statements may be embedded only within repetition statements

Which of the following encompasses the other three?

Control structure

The assignment operator (=) can be used to:

Copy data from one object to another.

Repeating a set of instructions a specific number of times is called ___________________ iteration.

Counter-controlled

Which language was developed by Microsoft in the early 1990s to simplify the development of windows applications? A.Visual C# B.Python C.Objective-C D.Visual basic

D

Which of the following is most closely associated with Moore's Law A.Every year or two, the price of computers has approximately doubled B.Object-oriented programming uses less memory than previous software-development methodologies C.Demand for communications bandwidth is decreasing dramatically each year D.Every year or two, the capacities of computers have approximately doubled without any increase in price

D

Which of the following is not one of the six logical units of a computer? A.Input unit B.Output unit C.Central processing unit D.Printer

D

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:

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

Pseudocode does not include:

Declarations

The function prototype double mySqrt ( int x );

Declares a function called mySqrt which takes an integer as an argument and returns a double

Which of the following statements will not produce a syntax error?

Declaring an object to be const.

All of the following can cause a fatal execution-time error except:

Dereferencing a variable that is not a pointer

All of the following can cause a fatal execution-time error except

Dereferencing a variable that is not a pointer.

An identifier's storage class:

Determines the period during which that identifier exists in memory

Overloaded functions must have:

Different parameter lists

Which of the following is not a valid enumeration statement?

Enum person {me, you, me};

Which of the following is most closely associated with Moore's Law?

Every year or two, the capacities of computers have approximately doubled without any increase in price.

Which operation does not take place in the following example? int x = 21; double y = 6; double z = 14; y = x / z; x = 5.5 * y;

Explicit conversion

Which of the following statements does not cause a syntax error to be reported by the C++ compiler?

Extra blank lines

Which of the following does not cause a syntax error to be reported by the C++ compiler?

Extra blank lines.

Recursion is to the base case as iteration is to what:

Failure of the loop continuation test.

Is this statement T or F about a function to which a built-in array is being passed? It always knows the size of the built-in array that is being passed

False

Is this statement T or F of class template vectors? A vector can store only data of type int.

False

Is this statement T or F: There is no mechanism in C++ for a constructor to call another constructor in the same class.

False

Is this statement T or F? A constructor cannot specify parameters

False

Is this statement about virtual functions T or F? They do not remain virtual down the inheritance heirarchy

False

T/F: By convention, variable-name identifiers begin with an uppercase letter, and every word in the name after the first word begins with a capital letter; this naming convention is known as camel case.

False

T/F: C++11's long long type supports values in the range - 2,147,483,647 to 2,147,483,647

False

T/F: In us today are more than a trillion general-purpose computers and trillions more cellphones, smartphones and other handheld devices

False

T/F: When a function terminates, the values of its local variables are preserved.

False

In an activity diagram for an algorithm, what does a solid circle surrounded by a hollow circle represent?

Final State

In an activity diagram for an algorithm, what does a solid circle surrounded by a hollow circle represent?

Final state

In an activity diagram for an algorithm, what does a solid circle surrounded by a hollow circle represent?

Final state.

Which of the following is true of function templates?

Formal type parameters act as placeholders for built-in types of user-defined types and are used to specify the types of arguments to the function, to specify the return type of the function, and to declare variable within the body of the function definition

Which of the following is true of function templates?

Formal type parameters act as placeholders for built-in types or user-defined types and are used to specify the types of arguments to the function, to specify the return type of the function, and to declare variables within the body of the function definition.

static data members of a certain class:

Have class scope.

The strtol and stroul functions do not

Have the same return types

Each standard library has a corresponding:

Header

Each standard library has a corresponding:

Header file

Assuming that text is a variable of type string, what will be the contents of text after the statement cin >> text; is executed if the user types Hello World! then presses Enter?

Hello

Which is the output of the following statements?

Hello World

[C++11]: Which of the following statements about inheriting base class constructors is false?

If an inherited base-class constructor has default arguments, the line of code in Part (a) causes the compiler to generate a derived-class constructor with the same default arguments.

[C++11]: Which of the following is true?

If you define any constructors with arguments, the compiler will not define a default constructor.

Which operation does not take place in the following example?

Implicit conversion.

Which of the following statements about nested if...else statements is true?

In an if body, an inner if...else executes only if the outer if statement's condition is true.

Member access specifiers (public and private) can appear:

In any order and multiple times.

Which of the following statements is true? *In distributed computing, an organization s computing is handled by a computer distributor. *In distributed computing, an organization s computing is distributed over networks to the sites where the organization s work is being performed. *In distributed computing, an organization s computing is performed at a central computer installation. *None of these.

In distributed computing, an organization s computing is distributed over networks to the sites where the organization s work is being performed.

A function prototype does not have to

Include parameter names

Which of the following statements is false?

Information in the memory unit is persistent—it is retained when the computer's power is turned off.

The is-a relationship represents.

Inheritance

______________ enables new classes to absorb the data and behaviors of existing classes and embellish these classes with new capabilities.

Inheritance

Assuming the following is the beginning of the constructor definition for class BasePlus-CommissionEmployee which inherits from class Point: BasePlusCommissionEmployee::BasePlusCommissionEmployee(string first, string last, string ssn, double sales, double rate, double salary) : CommissionEmployee(first, last, ssn, sales, rate) The line beginning with a colon(:)

Invokes the CommissionEmployee constructor with arguments.

A copy constructor:

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

A string array:

Is actually an array of pointers

A string array:

Is actually an array of pointers.

The conditional operator (?:):

Is the only ternary operator in C++

The conditional operator (?:):

Is the only ternary operator in C++.

Which of the following is false about a function to which a built-in array is being passed?

It always knows the size of the built-in array that is being passed

Which of the following is true of pseudocode?

It helps the programmer "think out" a program.

All of the following are reasons to use recursion except:

It maximizes execution performance

All of the following are reasons to use recursion except:

It maximizes execution performance.

Which of the following is not true of a destructor?

It releases the object's memory.

Which of the following best describes the first iteration of an insertion sort?

It takes the second element, and if it's less than the first element, it swaps it with the first element.

Which of the following is true?

It's an error if an initializer list has more initializers than there are elements in the array.

Given the following class declaration: line 1 class Widget { line 2 public: line 3 int x[50]; line 4 Widget (); line 5 Widget (int a, int b, int c); line 6 Widget (float a); line 7 int GetValue() const; line 8 int y; line 9 void SetValue(int Value); line 10 private: line 11 TimeType z; line 12 int PutValue(int Value); line 13 }; Identify the private member functions in the class Widget. (Mark all that apply.)

Line 12

When composition (one object having another object as a member) is used:

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

In a switch statement:

Multiple actions in a case do not need to be enclosed in braces.

Class templates

Must put template<typename Type> before the class definition

An explicit constructor:

Must take exactly one argument.

Type-safe linkage is ensured by

Name mangling

Type-safe linkage is ensured by:

Name mangling.

Having a loop within a loop is known as:

Nesting

Can a subscript be an expression?

No (False)

is the insertion sort algorithm the most efficient of all sorting algorithms for large arrays?

No (False)

________ models software in terms similar to those that people use to describe real-world objects.

Object-oriented design

What does the following statement declare? int *countPtr, count;

One pointer to an int and one int variable

Which forms of inheritance are is-a relationships?

Only public.

Which of the following is not part of a computer s hardware? The hard disk. The keyboard. The operating system. The screen.

Operating system

A copy constructor must receive its argument by reference because:

Otherwise infinite recursion occurs.

If grade has the value of 60, what will the following code display? if ( grade >= 60 ) cout << "Passed";

Passed

If grade has the value of 60, what will the following code print? If ( grade >= 60 ) Cout << "Passed";

Passed

Which of the following operations has the highest precedence?

Postincrement

Which of the following is not a good example of a hierarchy likely to be modeled by inheritance?

Prime numbers.

What will the following program segment do? int counter = 1; do { cout << counter << " "; } while (++counter <= 10);

Print the numbers 1 through 10

What will the following program segment do? int counter{1}; do { cout << counter << " "; } while (++counter <= 10);

Print the numbers 1 through 10.

Which of the following is not one of the six logical units of a computer?

Printer

Which of the following is not one of the six logical units of a computer? Printer unit. Central processing unit. Output unit. Input unit.

Printer unit

Specifying the order in which statements are to be executed in a computer program is called:

Program control.

Which of the following is true?

Random numbers produced by the rand function are nondeterministic.

Pointers cannot be used to:

Reference values directly

Which of the following is not a disadvantage of default memberwise copy with objects containing pointers?

Requiring the explicit overloading of the assignment operator

sizeof:

Returns the total number of bytes in a variable.

What does sizeof do?

Returns the total number of bytes in a variable. (8 bytes in a bit, 4 bits in an int)

Indefinite repetition is controlled by a:

Sentinel value

In indefinite repetition, an input value:

Should always be evaluated before being processed

Should never be modified.

Should always be evaluated before being processed.

An example of a unary operator is:

The ! logical operator

What happens when two blocks, one nested inside of the other, both declare variables with the same identifier? (Assume that the outer block declares its variable before the opening left-brace of the inner block.)

The "outer" variable is hidden while the "inner" variable is in scope.

What happens when two blocks, one nested inside of the other, both declare variables with the same identifier? (Assume that the outer block declares its variable before the opening left-brace of the inner block.)

The 'outer' variable is irretrievable lost when the 'inner' variable is declared

______ is a graphical language that allows people who design software systems to use an industry standard notation to represent them

The Unified Modeling Language

If a do...while structure is used:

The body of the loop will execute at least once.

If a do...while structure is used:

The body of the loop will execute at least one

The compiler will implicitly create a default constructor if:

The class does not define any constructors.

Which of the following statements is false?

The commas used to separate the arguments in a function call are comma operators.

All of the following are true of functions except:

The definition of a function usually is visible to other functions

:All of the following are true of functions except:

The definition of a function usually is visible to other functions.

All of the following are true of functions except:

The definition of a function usually is visible to other functions.

Calling a member function of an object requires which item?

The dot operator.

Which of the following statements is false?

The impressive functions performed by computers involve only the simplest manipulations of 1s and 2s.

Which of the following is not included in a function's activation record?

The name of the function

The argument list of a function call must match, or be consistent with, the parameter list of the called function in all of the following details, except:

The names of arguments/parameters in the list

The argument list of a function call must match, or be consistent with, the parameter list of the called function in all of the following details, except:

The names of arguments/parameters in the list.

The linker links: The executable code with primary memory. The primary memory with the CPU. The source code with the object code. The object code with the external libraries.

The object code with the external libraries.

The linker links:

The object code with the libraries

In a typical nested for loop (not a range-based for loop) used to process a 2D array, following the end of each execution of the inner for loop:

The outer for loop increments its counter variable

Because the postfix increment operator returns objects by value and the prefix increment operator returns objects by reference:

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

An uninitialized local variable contains:

The value last stored in the memory location reserved for that variable.

Which of the following is not true of a constructor and destructor of the same class?

They both are able to have default arguments

Which of the following is not true of a constructor and destructor of the same class?

They both are able to have default arguments.

Which of the following is not true of pointers to functions?

They can not be assigned to other function pointers

Which of the following is true of a pseudocode program?

They help the programmer "think out" a program.

Comparing pointers and performing pointer arithmetic on them is meaningless unless:

They point to elements of the same array.

Which of the following is not true of static local variables?

They're accessible outside of the function in which they define

The unary scope resolution operator is used

To access a global variable when a local variable of the same name is in scope

The unary scope resolution operator is used:

To access a global variable when a local variable of the same name is in scope.

The conventional way to distinguish between the overloaded preincrement and postincrement operators (++) is:

To make the argument list of postincrement include an int.

[C++11] Which of the following statements about scoped enumerations is false?

To reference a scoped enum constant, you must qualify the constant with the scoped enum's type name and the scope-resolution operator (:), as in MaritalStatus:SINGLE.

Is this statement T or F for function templates: Formal type parameters act as placeholders for built-in types or user-defined types and are used to specify the types of arguments to the function, to specify the return type of the function, and to declare variables within the body of the function definition.

True

T/F: There are representational errors, when precise decimal dollar amounts and interest rates are stored as doubles.

True

If the function Int volume ( int x = 1, int y = 1, int z = 1 ); Is called by the expression volume ( 3), how many default arguments are used?

Two

End-of-line comments that should be ignored by the compiler are denoted using:

Two forward slashes ( // )

End-of-line comments that should be ignored by the compiler are denoted using:

Two forward slashes (//).

At what point does a class' constructor get called?

When the constructor is created.

When should base class members be declared protected?

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

Which of the following is false?

You should always try to write the fastest, smallest code possible before attempting to make it simple and correct

Which of the following is false?

You should always try to write the fastest, smallest code possible before attempting to make it simple and correct.

Which of the following is the escape character?

\

The escape sequence for a newline is:

\n

[C++14]: The code ", have a great day!"s is an example of ________:

a string-object literal.

Keyword public is a(n) _____________________.

access specifier

Returning references to non-const, private data:

allows private member variables to be modified, thus "breaking encapsulation"

Using a while loop's counter-control variable in a calculation after the loop ends often causes a common logic error called:

an off-by-one error

Linear search can be used on:

any of the above

From most restrictive to least restrictive, the access modifiers are: a.protected, private, public b.private, protected, public c.private, public, protected d. protected, public, private

b.private, protected, public

The most basic unit of data on a computer is the

bit

Variables defined inside a member function of a class have

block scope

Which of the following is correct when labeling cases in a switch structure?

case 1:

cin.getline(superstring, 30); is equivalent to which of the following?

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

To declare class subClass a privately derived class of superClass one would write:

class subclass : private superClass

The process of instructing the computer to solve a problem is called_______________.

computer programming

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; }

constructor called, constructor called, destructor called, destructor called,

Which of the following is false?

continue and break statements may be embedded only within iteration statements.

The operator ___________ reclaims memory previously allocated by new.

delete

Which of the following is a repetition statement?

do...while

C++ programs normally go through six phases— _____, _________, __________, _______, _______, and _______________.

edit, preprocess, compile, link, load, execute

When a compiler encounters a function parameter for a single-subscripted array of the form int a[], it converts the parameter to:

int *a

C++ provides for ___________ , which allows a derived class to inherit from many base classes, even if the base classes are unrelated.

multiple inheritance

Which of the following best describes the array name n in the declaration int n[10];?

n is a constant pointer to nonconstant data

Which of the following best describes the array name n in the declaration int n[10];?

n is a constant pointer to nonconstant data.

The operator ________ dynamically allocates memory for an object of a specified type and returns a(n) ________ to that type.

new, pointer

C++ Standard Library function getline, from the <string> header, reads characters up to, but not including, a(n)________ (which is discarded), then places the characters in a string.

newline

A member function should be static if it does not access ____________ class members.

non-static.

C++ provides a number of features that "spruce up" the C language, but more importantly, it provides capabilities for ________ that were inspired by the Simula simulation programming language.

object-oriented programming

[C++11]: Overloaded operators can be used to test a stream's state in conditions. The operator! member function, inherited into the stream classes from class basic_ios, returns true if the badbit, the failbit or both are true. The ________ member function (added in C++11) returns false if the badbit is true, the failbit is true or both are true.

operator bool

Base class means

parent class

____________ class members are accessible anywhere an object of the class is in scope.

public

The process of determining if an array contains a particular key value is called ______________ the array.

searching

Which of the following is a parameterized stream manipulator used to format output?

setw

Which of the following is not a kind of inheritance in C++?

static

Which of the following code segments prints a single line containing hello there with the words separated by a single space?

std::cout << "hello"; std::cout << " there"

Which of the following code segments prints a single line containing hello there with the words separated by a single space?

std::cout << "hello"; std::cout << " there";

Which of the following is not a syntax error?

std::cout<<"Hello world! ";

The number used to refer to a particular element of an array is called its ______________

subscript

What is wrong with the following while loop? while (sum <= 1000) { sum = sum - 30; }

sum = sum - 30 should be sum = sum + 30 or else the loop may never end.

What is wrong with the following while loop? while ( sum <= 1000 ) sum = sum - 30;

sum = sum - 30 should be sum = sum +30 or else the loop may never end

The correct order in which an exception is detected and handled is:

try, throw, catch

An array that uses two subscripts is referred to as a(n) ________________ array.

two-dimensional

The __________ operator returns a reference to a __________ object:

typeid, type_info

[C++11]: Which of the following statements creates a uniform_int_distribution object for producing values in the range -10 to 20?

uniform_int_distribution<int> randomInt {-10,20}

Polymorphism is implement via

virtual functions and dynamic binding

Assuming that x is equal to 4, which of the following statements will not result in y containing the value 5 after execution?

y = x++;

What is the default initial value of a String?

""

Assuming that text is a variable of type string, what will be the contents of text after the statement cin >> text; is executed if the user types Hello World! then presses Enter?

"Hello"

Assuming that the string object text contains the string "Hello!!! ", the "expression text.substr( 2 , 5 ) would return a string object containing the string:

"llo!! ".

Which of the following preprocessor directives does not constitute part of the preprocessor wrapper?

#include

Assuming that GradeBook.h is found in the current directory and the iostream header file is found in the C++ Standard Library header file directory, which of the following preprocessor directives will fail to find its desired header file?

#include <GradeBook.h>

Any file that uses a class can include the class's header via a(n) ____________ preprocessing directive.

#include.

To make numeric literals more readable, C++14 allows you to insert between groups of digits in numeric literals the digit separator ' (a single-quote character).

' (a single quote)

To make numeric literals more readable, C++14 allows you to insert between groups of digits in numeric literals the digit separator ________

' (a single-quote character).

[C++11]: To prevent class objects from being copied or assigned, you can:

(a) or (b)

For which of the following operators does C++ not specify the order of evaluation of its operands?

+

The UML models operations by listing the operation name preceded by an access modifier. A(n) ________ indicates a public operation in the UML

+

The UML models operations by listing the operation name preceded by an access modifier. A(n) ________ indicates a public operation in the UML.

+

Which of the following can have a pointer as an operand?

++

Given the following code: int x = 4; int y = 5; int n; int * p; int *q; p = &x; q = &y; p = q; n = -1; *p = n; *q = n + *p + *q; Question: What is *p equal to?

-3

The operators that cannot be overloaded are _________, __________, ___________ and ___________.

., ?:, .*, and ::

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

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

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.

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.

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.

List two benefits that C++ classes have over C-style structs:

1. Allow for different data protection. I.e. private, public. 2. Allow for polymorphic behavior to take place.

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.

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.

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.

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.

Using the following function definition, the parameter list is represented by: A B ( C ) { D } 1. C. 2. D. 3. B. 4. A.

1. C.

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.

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.

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 function prototype double mySqrt( int x); 1. Declares a function called mySqrt which takes an integer as an argument and returns a double. 2. Defines a function called double which calculates square roots. 3. Defines a function called mySqrt which takes an argument of type x and returns a double. 4. Declares a function called mySqrt which takes a double as an argument and returns an integer.

1. Declares a function called mySqrt which takes an integer as an argument and returns a double.

An identifier's storage class: 1. Determines the period during which that identifier exists in memory. 2. Determines where the identifier can be referenced in a program. 3. Determines whether an identifier is known only in the current source file or in any source file with proper declarations. 4. All of the above.

1. Determines the period during which that identifier exists in memory.

Functions can: 1. Do any of the above. 2. Return a result to the caller function. 3. Be used as building blocks to create new programs. 4. Be reused any number of times.

1. Do any of the above.

When an argument is passed-by-value, changes in the calling function __________ affect the original variable's value; when an argument is passed call-by-reference, changes __________ affect the original variable's value. 1. Do not, do. 2. Do not, do not. 3. Do, do not. 4. Do, do.

1. Do not, do.

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.

Labels are the only identifiers with: 1. Function scope. 2. File scope. 3. Block scope. 4. Function-prototype scope.

1. Function scope.

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.

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

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.

All of the following are true of functions except: 1. The definition of a function usually is visible to other functions. 2. They define specific tasks that can be used at many points in a program. 3. The implementation of a function is hidden from the caller. 4. A function call must specify the name and arguments of the function.

1. The definition of a function usually is visible to other functions.

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.

Which of the following is not included in a function's activation record? 1. The name of the function. 2. Parameter values received from its caller. 3. Local variables it has declared. 4. The return address of its caller function.

1. The name of the function.

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.

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;

The unary scope resolution operator is used: 1. To access a global variable when a local variable of the same name is in scope. 2. To access any variable in an outer block when a local variable of the same name is in scope. 3. To access a global variable when it is out of scope. 4. To access a local variable with the same name as a global variable.

1. To access a global variable when a local variable of the same name is in scope.

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.

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

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

1. fill

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 };

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 };.

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

Which of the following is not included in math library? 1. log. 2. pow. 3. floor. 4. ln.

1. log.

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 )

What is an advantage of using references (int&) over pointers (int*)?

1. references cannot be changed. 2.references don't produce dangling pointers, or require a change in syntax. Note: However references cannot be reassigned to point to something else, but a pointer can be.

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!()

Which of the following expressions returns the trigonometric sine of x? 1. sin( x ). 2. sine( x ). 3. trig_sin( x ). 4. trig_sine( x ).

1. sin( x ).

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 );

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

The statement while ( --counter >= 1 ) counter % 2 ? cout << "A" : cout << "B"; cannot be rewritten as: 1. while ( counter >= 1 ) if ( counter % 2 ) cout << "A"; else cout << "B";. --counter; 2. while ( --counter >= 1 ) if ( counter % 2 ) cout << "A"; else cout << "B";. 3. while ( counter > 1 ) { --counter; if ( counter % 2 ) cout << "A"; else cout << "B"; }. 4. while ( --counter >= 1 ) counter % 2 == 0 ? cout << "B" : cout << "A";.

1. while ( counter >= 1 ) if ( counter % 2 ) cout << "A"; else cout << "B";. --counter;

What is the value of result after the following C++ statements execute? int a{4}; int b{12}; int c{37}; int d{51}; int result{d % a * c + a % b + a};

119

A double subscripted array declared as array<array<int, 5>, 3> values; has how many elements?

15

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

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.

An activation record will be popped off the function call stack whenever: 1. A function calls itself. 2. A function returns control to its caller. 3. A function calls another function. 4. A function declares a local variable.

2. A function returns control to its caller.

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.

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 is not one the rules for forming structured programs? 1. Begin with the "simplest activity diagram." 2. Any transition arrow can be reversed. 3. Any action state can be replaced by two action states in sequence. 4. Any action state can be replaced by any control statement.

2. Any transition arrow can be reversed.

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.

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.

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

Recursion is to the base case as iteration is to what: 1. A selection structure. 2. Failure of the loop continuation test. 3. The counter. 4. A repetition structure.

2. Failure of the loop continuation test.

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.

If a function's program logic and operations are identical for each data type it could receive as argument(s) then a __________ should be used. 1. Overloaded function. 2. Function template. 3. Recursive function. 4. Macro.

2. Function template.

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

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

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 the following function prototype? void functionA( void ); 1. It does not receive any arguments. 2. It could have been written functionA( void );. 3. It could have been written void functionA( );. 4. It does not return a value.

2. It could have been written functionA( void );.

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

In a switch statement: 1. A break is required after each case. 2. Multiple actions in a case do not need to be enclosed in braces. 3. A default case is required. 4. A break is required after the default case.

2. Multiple actions in a case do not need to be enclosed in braces.

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.

What will the following program segment do? int counter = 1; do { cout << counter << " "; } while ( ++counter <= 10 ); 1. Print the numbers 1 through 9. 2. Print the numbers 1 through 10. 3. Cause a syntax error. 4. Print the numbers 1 through 11.

2. Print the numbers 1 through 10.

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.

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.

The OR (||) operator: 1. Has higher precedence than the AND (&&) operator. 2. Stops evaluation upon finding one condition to be true. 3. Associates from right to left. 4. Is a ternary operator.

2. Stops evaluation upon finding one condition to be true.

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 (>>).

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.

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.

If a do...while structure is used: 1. Counter-controlled repetition is not possible. 2. The body of the loop will execute at least once. 3. An off-by-one error will not occur. 4. An infinite loop will not take place.

2. The body of the loop will execute at least once.

Call-by-reference can achieve the security of call-by-value when: 1. A large argument is passed in order to improve performance. 2. The const qualifier is used. 3. A pointer to the argument is used. 4. The value being passed is small.

2. The const qualifier is used.

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.

If a variable is declared in the initialization expression of a for structure, then: 1. It can not be used in any structures that are nested in that for structure. 2. The scope of the variable is restricted to that particular for loop. 3. It retains its final value after the loop is finished. 4. It is automatically reinitialized to zero once the loop is finished.

2. The scope of the variable is restricted to that particular for loop.

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.

Which of the following is a bad programming practice? 1. Placing vertical spacing above and below control structures. 2. Using floating-point values for counters in counter-controlled repetition. 3. Indenting the statements in the body of each control structure. 4. Nesting multiple repetition structures one within another.

2. Using floating-point values for counters in counter-controlled repetition.

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 true? 1. The initialization and increment expressions can be comma-separated lists. 2. You must declare the control variable outside of the for loop. 3. The three expressions in the for structure are optional. 4. A for loop can always be used to replace a while loop, and vice versa.

2. You must declare the control variable outside of the for loop.

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

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.

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.

switch can be used to test: 1. float constants. 2. int constants. 3. string constants. 4. all types of constants.

2. int constants.

Variables are also known as: 1. rvalues, and cannot be used as lvalues. 2. lvalues, and cannot be used as rvalues. 3. Constant variables. 4. lvalues, but can be used as rvalues.

2. lvalues, and cannot be used as rvalues.

Which of the following is not one of the C++ control structures? 1. switch. 2. main. 3. do...while. 4. if.

2. main.

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

2. middle

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()

Depending on the circumstances, the compiler may ignore the storage class specifier: 1. extern. 2. register. 3. static. 4. auto.

2. register.

The ____________, __________ and ____________ are the only three forms of control necessary. 1. switch, if, else. 2. sequence, selection, repetition. 3. break, continue, if...else. 4. for, while, do...while.

2. sequence, selection, repetition.

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

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

The rand function generates a data value of the type: 1. short int. 2. unsigned int. 3. long int. 4. int.

2. unsigned int.

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)

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?

2012

What value does function mystery return when called with a value of 4? int mystery (int number) { if (number <= 1) { return 1; } else { return number * mystery(number - 1); } }

24

What value does function mystery return when called with a value of 4? int mystery ( int number ) { If ( number <= 1 ) Return 1; Else Return number * mystery (number - 1 ); }

24

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.

An operator that associates from right to left is: 1. !=. 2. ,. 3. ?:. 4. ().

3. ?:.

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.

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 data types can be used to represent integers? 1. long. 2. char. 3. All of the above. 4. short.

3. All of the above.

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.

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

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.

Consider the execution of the following for loop for (int x = 1; x < 5; increment ) cout << x + 1 << endl; If the last value printed is 5, which of the following might have been used for increment? 1. ++x. 2. x++. 3. Any of the above. 4. x += 1.

3. Any of the above.

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.

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

A recursive function is a function that: 1. Returns a double. 2. Takes 3 arguments. 3. Calls itself, directly or indirectly. 4. Is inside of another function.

3. Calls itself, directly or indirectly.

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.

srand: 1. Should be used instead of rand to generate truly random numbers. 2. Is unnecessary in C++. 3. Can use the time function's return value as an optimal seed value. 4. Should be called before each call to rand.

3. Can use the time function's return value as an optimal seed value.

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.

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.

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.

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.

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 .

Each standard library has a corresponding: 1. Cd-rom. 2. Variable type. 3. Header file. 4. Function.

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

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.

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.

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.

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.

The OR (||) operator: 1. Has higher precedence than the AND (&&) operator. 2. Is a ternary operator. 3. Stops evaluation upon finding one condition to be true. 4. Associates from right to left.

3. Stops evaluation upon finding one condition to be true.

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

The argument list of a function call must match, or be consistent with, the parameter list of the called function in all of the following details, except: 1. The number of arguments/parameters in the list. 2. The types of arguments/parameters in the list. 3. The names of arguments/parameters in the list. 4. The argument list and parameter list must match in All of these details.

3. The names of arguments/parameters in the list.

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 static local variables? 1. They retain their values when the function in which they are defined terminates. 2. They are initialized to zero if not explicitly initialized by the programmer. 3. They are accessible outside of the function in which they are defined. 4. They can be of type int.

3. They are accessible outside of the function in which they are defined.

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.

The only identifiers that can be reused elsewhere in a program without any ambiguity are: 1. Global variables. 2. Those in the parameter list of a function definition. 3. Those in the parameter list of a function prototype. 4. static local variables.

3. Those in the parameter list of a function prototype.

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.

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.

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 correct when labeling cases in a switch structure? 1. Case1. 2. Case 1. 3. case 1. 4. case1.

3. case 1.

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

3. cin

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 for headers is not valid? 1. for ( int i = 0: i < 10; ). 2. int i = 0; for ( ; i < 10; i++ ). 3. for ( int i = 0; int j = 5; ; i++ ). 4. for ( int i = 0; i < 10; i++ ).

3. for ( int i = 0; int j = 5; ; i++ ).

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

Converting from type ________ to type ________ will result in the loss of data. 1. bool, char. 2. float, double. 3. int, char. 4. short, long.

3. int, char.

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.

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

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

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

3. wchar_t

In the expression n = x + rand() % y; 1. y is the shifting value. 2. x is the scaling value. 3. y is the scaling value. 4. Both y is the shifting value and x is the scaling value.

3. y is the scaling value.

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. &=

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.

A function prototype can always be omitted when: 1. A function is invoked before it is first defined. 2. A function takes no arguments. 3. A function does not return a value. 4. A function is defined before it is first invoked.

4. A function is defined before it is first invoked.

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.

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.

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

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.

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.

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 inline keyword: 1. Should be used with all frequently used functions. 2. Increases function-call overhead. 3. Can decrease program size but increase the function's execution time. 4. Can reduce a function's execution time but increase program size.

4. Can reduce a function's execution time but increase program size.

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.

In regards to default arguments, which of the following is false? 1. When an argument is omitted in a function call, the default value of that argument is automatically inserted by the compiler and passed in the function call. 2. They must be the rightmost (trailing) arguments in a function's parameter list. 3. Default values can be constants. 4. Default values cannot be global variables or function calls.

4. Default values cannot be global variables or function calls.

In C++, the condition ( 4 > y > 1 ): 1. Evaluates correctly and could not be replaced by ( 4 > y && y > 1 ). 2. Evaluates correctly and could be replaced by ( 4 > y && y > 1 ). 3. Does not evaluate correctly and should not be replaced by ( 4 > y && y > 1 ). 4. Does not evaluate correctly and should be replaced by ( 4 > y && y > 1 ).

4. Does not evaluate correctly and should be replaced by ( 4 > y && y > 1 ).

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.

Which of the following is not a part of a UML state diagram? 1. A solid circle indicating the initial state. 2. Rounded rectangles representing states. 3. Arrows with accompanying event description text representing transitions. 4. Fractions beside each state indicating the likelihood of entering that state.

4. Fractions beside each state indicating the likelihood of entering that state.

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.

All of the following are reasons to use recursion except: 1. An iterative solution is not apparent. 2. The resulting program is easier to debug. 3. It more naturally mirrors the problem. 4. It maximizes execution performance.

4. It maximizes execution performance.

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.

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.

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.

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.

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.

Which of the following does the C++ compiler not examine in order to select the proper overloaded function to call? 1. The number of arguments in the function call. 2. Types and order of the arguments in the function call. 3. It examines all of the above. 4. The return type of the function.

4. The return type of the function.

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.

A variable that can have values only in the range 0 to 65535 is a: 1. Four-byte int. 2. Four-byte unsigned int. 3. Two-byte int. 4. Two-byte unsigned int.

4. Two-byte unsigned int.

Of the following, which is not a logic error? 1. Failing to initialize counter and total variables before the body of a loop. 2. Not placing curly braces around the body of an if that contains two statements. 3. Using == to assign a value to a variable. 4. Using commas instead of the two required semicolons in a for header.

4. Using commas instead of the two required semicolons in a for header.

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.

Which of the following is false? 1. The effects of break and continue statements can be achieved by structured programming techniques. 2. break and continue statements can make a program perform faster than with the corresponding structured techniques. 3. Many programmers feel that break and continue violate structured programming. 4. You should always try to write the fastest, smallest code possible before attempting to make it simple and correct.

4. You should always try to write the fastest, smallest code possible before attempting to make it simple and correct.

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.

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( ' ' );

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

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

4. g

The expression if ( num != 65 ) cannot be replaced by: 1. if ( num > 65 || num < 65 ). 2. if ( !( num == 65 ) ). 3. if ( num - 65 ). 4. if ( !( num - 65 ) ).

4. if ( !( num - 65 ) ).

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

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 is a parameterized stream manipulator used to format output? 1. right. 2. fixed. 3. left. 4. setw.

4. setw.

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

Assuming the following pseudocode for the Fibonacci series, what is the value of the 5th Fibonacci number (fibonacci (5))? fibonacci(0) = 0 fibonacci(1) = 1 fibonacci(n) = fibonacci(n - 1) + fibonacci(n - 2)

5

Assuming the following pseudocode for the Fibonacci series, what is the values of fibonacci(5)? fibonacci( 0 ) = 0 fibonacci( 1 ) = 1 fibonacci( n ) = fibonacci ( n -1 ) + fibonacci ( n - 2 )

5

Consider the following code, assuming that x is an int with an initial value of 12 if(x = 6) { cout << x; } What is the output?

6

Consider the following code, assuming that x is an int with an intial value of 12 if ( x = 6 ) cout << x; What is the output?

6

What is the final value of x after performing the following operations? int x = 21; double y = 6; double z = 14; y = x / z; x = 5.5 * y;

8

Which of the following C++ Standard Library headers does not contain a C++ Standard Library container class?

<string>

Which of the following C++ Standard Library headers does not contain a C++ Standard Library container class?

<string>.

Which of the following is not an arithmetic operator?

=

An operator that associates from right to left is

?:

Which of the following statements is false? A.The impressive functions performed by computers involve only the simplest manipulations of 1s and 2s B.ASCll is a popular subset of Unicode C.Fields are composed of characters of bytes D.On some operating systems, a file is viewed simply as a sequence of bytes

A

Which of the following statements about friend functions and friend classes is false?

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

A constructor can specify the return type:

A constructor cannot specify a return type.

Which of the following statements is false?

A constructor cannot specify parameters.

To handle situations where a loop must reinitialize a variable at the beginning of each iteration, such re-initialization could be performed by:

A declaration inside the loop body

A pointer can not be assigned to:

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

A pointer cannot be assigned to:

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

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.

Which of the following tasks cannot be performed using a range-based for loop?

Accessing the element's subscript.

Structure variable declarations can be incorporated into a structure definition by placing a comma-separated list of variable names:

After the right brace and before the semicolon

Which of the following data types can be used to represent integers?

All of the above

Which of the following does counter-controlled repetition require?

All of the above

Assuming the definition, class BasePlusCommissionEmployee : public CommissionEmployee which of the following is false?

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

Returning references to non-const, private data:

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

Using a while loop's counter-control variable in a calculation after the loop ends often causes a common logic error called:

An off-by-one error

[C++11]—Which of the following statements is false?

An unscoped enum's underlying type is independent of its constants' values but is guaranteed to be large enough to store those values.

17.7 Q2: A random access file is organized most like a(n):

Answer: Array.

17.2 Q3: The data hierarchy, arranged from smallest to largest, is:

Answer: Bit, byte, field, record, file.

17.4 Q1: Select the false statement.

Answer: C++ files include information about their structure.

17.8 Q2: Select the false statement. The reinterpret_cast operator:

Answer: Changes the value of the object to which its operand points.

17.12 Q1: Select the false statement. When objects are saved to a file:

Answer: Different types of objects cannot be written to the same file.

17.8 Q3: To write fixed-length records, use file open mode:

Answer: ios::binary.

Consider the execution of the following for loop For (int x = 1; x < 5; increment ) Cout << x + 1 << endl; If the last value printed is 5, which of the following might have been used for increment?

Any of the above

Consider the execution of the following for loop for (int x = 1; x < 5; increment) { cout << x + 1 << endl; } If the last value printed is 5, which of the following might have been used for increment?

Any of the above.

Linear search can be used on:

Any of the above.

Which of the following is not one of the rules for forming structures programs?

Any transition arrow can be reversed

Which of the following is not one the rules for forming structured programs?

Any transition arrow can be reversed.

Base class constructors and assignment operators:

Are not inherited by derived classes.

The purpose of stack unwinding is to:

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

In order to calculate the __________ of an array of values, the array values must first be summed.

Average

Today, virtually all new major operating systems are written in: A.Objective-C B.C or C++ C.Visual C# DAda

B

Which of the following statements is false? A.The concepts of icons, menus, and windows were originally developed by Xerox Park B.Windows is an open source operating system C.The software that contains the core components of the operating system is called the kernel D.Linux source code is available to the public for examination and modification

B

Which of the following statement is true?

Base-class constructors are not automatically inherited by derived classes.

Which statement is false?

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

For operators overloaded as non-static member functions:

Binary operators can have one argument, and unary operators cannot have any.

Let Bit1 = Bit2 = 1. Which of the following does not have the same result as the others?

Bit1 ^ Bit2

Which of the following statements is false? A.Object-oriented programming is today's key programming methodology B.C++ is standardized worldwide through the International Organization for Standardization C.Hardware controls software D.In use today are more than a billion general-purpose computers and billions more cell phones, smartphones and handheld devices (such as tablet computers)

C

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

static member functions:

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

The inline keyword:

Can reduce a function's execution time but increase program size

The inline keyword:

Can reduce a function's execution time but increase program size.

Referencing elements outside the array bounds with the [] operator:

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

The data type bool:

Can take on values true and false

The data type bool:

Can take on values true and false.

The other classes or functions that use a certain class are commonly referred to as its: Data members. Methods. Clients. Member functions.

Clients

Which of the following statements is true?

Compilers translate high-level language programs into machine language programs.

Which of the following statements is false? A.Speaking to your computer is a form of input B.Playing a video is an example of an output C.Multi-core processor implements several processors on a single integrated-circuit chip D.Information in the memory unit is persistent it is retained when the computers power is turned off

D

which statement is false? A.Classes are reusable software components B.A class is to an object as a blueprint is to a house C.Performing a task in a program requires a method D. A class is an instance of its object

D

which statement is false? A.Object-oriented programming is today's key programming methodology B.C++ is one of today's most popular software development languages C.Software commands computer hardware to perform tasks D. In use today are more than a trillion general-purpose computers and trillions more cellphones, smartphones and other handheld devices

D.

Assuming the following pseudocode for the Fibonacci series, what is the value of the 5th Fibonacci number (fibonacci ( 5 ))? fibonacci( 0 ) = 0 fibonacci( 1 ) = 1 fibonacci( n ) = fibonacci( n - 1 ) + fibonacci( n - 2 ) A. 1. B. 3. C. 7. D. 5.

D. 5.

If the function int volume( int x = 1, int y = 1, int z = 1 ); is called by the expression volume( 3 ), how many default arguments are used? A. None. B. Three. C. One. D. Two.

D. Two.

In regards to default arguments, which of the following is false?

Default values cannot be global variables or function calls

In regards to default arguments, which of the following is false?

Default values cannot be global variables or function calls.

Overloaded functions must have:

Different parameter lists.

Functions can

Do all of the above

When an argument is passed-by-value, changes in the called function __________ affect the original variable's value; when an argument is passed call-by-reference, changes in the called function __________ affect the original variable's value.

Do not, do.

In C++, the condition ( 4 > y > 1 ):

Does not evaluate correctly and should be replaced by ( 4 > y && y > 1)

In C++, the condition (4 > y > 1):

Does not evaluate correctly and should be replaced by (4 > y && y > 1).

In C++, the condition (4>y>1)

Does not evaluate correctly and should be replaced by (4>y&& y>1)

Using square brackets ([]) to retrieve vector elements __________ perform bounds checking; using member function at to retrieve vector elements __________ perform bounds checking.

Does not, does.

Is this statement T or F? C++11 added type char64_t to handle the new double-width Unicode characters.

False

Is this statement T or F? A rethrown exception must have been fully processed at the time it was rethrown.

False

Is this statement T or F? C++ ensures that you cannot "walk off" either end of an array.

False

Is this statement T or F? C++11 added the keyword using as another mechanism for creating type aliases. The following declaration is equivalent to the typedef in part b): using Card* = CardPtr;

False

Is this statement T or F? Depending on the compiler: a failed new operation can automatically be caught at compile time

False

Is this statement T or F? The default range of a uniform_int_distribution is from 0 to 32767.

False

Is this statement about exception handling T or F? Bounds checking is performed at execution time with vector member function at, and if a subscript is within the bounds of the array, the member function throws an out_of_bounds exception.

False

Is this statement about friend functions and friend classes T or F? A class can either grant friendship to or take friendship from another class using the friend keyword.

False

Is this statement about operator overloading T or F? Certain overloaded operators can change the number of arguments they take.

False

Which of the following is not a key organization in the open-source community?

Firefox

[C++11]: Which of the following is false?

First and third choice.

Which of the following languages is used primarily for scientific and engineering applications?

Fortran

Which of the following languages is used primarily for scientific and engineering applications? COBOL. Pascal. Fortran. Basic.

Fortran

Labels are the only identifiers with:

Function scope.

If a set of functions have the same program logic and operations and differ only in the data type(s) each receives as argument(s) then a(n) __ should be used.

Function template

If a set of functions have the same program logic and operations and differ only in the data type(s) each receives as argument(s) then a(n) __________ should be used.

Function template.

protected base class members cannot be accessed by:

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

C++ is a: Typeless language. Pure object-oriented language. Hybrid object-oriented language. Subset of the C Language.

Hybrid object-oriented language

_____ is a communication protocol used to send information over the web

HyperText Markup Language (HTML)

________ is a communications protocol used to send information over the web.

HyperText Transfer Protocol (HTTP).

Which of the following statements about pointer initialization and values is false?

In the new standard, you should use the constant null_ptr to initialize a pointer instead of 0 or NULL.

Which of the following statements is false?

In use today are more than a trillion general-purpose computers and trillions more cellphones, smartphones and other handheld devices.

A function prototype does not have to:

Include parameter names.

(*max)(num1, num2, num3);:

Is a call to the function pointed to by max.

Which of the following is false about a function to which a built-in array is being passed?

It always knows the size of the built-in array that is being passed.

Which of the following is false about the new operator and the object for which it allocates memory?

It automatically destroys the object after main is exited

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):

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 statements about object-oriented design is false? OOD encapsulates attributes and operations into objects. OOD takes advantage of inheritance relationships. OOD focuses on actions (verbs). Each class can be used to create multiple objects.

OOD focuses on actions (verbs).

Which of the following statements is false (assume we're referring to class Time)?

Often a class's interface and implementation will be created and compiled by one programmer and used by a separate programmer who implements the client code that uses the class.

What type of software made it cheaper and easier to start Web 2.0 companies? None of these. Open source. Proprietary. Vaporware.

Open source

The std::endl stream manipulator ___.

Outputs a newline and flushes the output buffer

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 technique does the function use to refer to array elements?

Pointer/offset notation.

Recursion is memory-intensive because:

Previous function calls are still open when the function calls itself and the activation records of these previous calls still occupy space on the call stack

Recursion is memory-intensive because:

Previous function calls are still open when the function calls itself and the activation records of these previous calls still occupy space on the call stack.

______ involves reworking programs to make them clearer and easier to maintain while preserving their correctness and functionality

Refactoring

Pointers cannot be used to:

Reference values directly.

Which software product release category is "generally feature compete and supposedly bug free, and ready for use by the community?"

Release candidate

Which software product release category is "generally feature complete and supposedly bug free, and ready for use by the community?"

Release candidate.

Member function definitions:

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

When it isn't known in advance how many times a set of statements will be repeated, a(n) _______________ value can be used to terminate the iteration.

Sentinel

Indefinite repetition is controlled by a:

Sentinel value.

The ___, ___ and ___ are the only three forms of control necessary.

Sequence, selection, repetition

The prototypes of overloaded cast operator functions do not:

Specify a return type.

Which of the following is not one of the three general types of computer languages?

Spoken languages.

The OR ( | | ) operator:

Stops evaluation upon finding one condition to be true

The OR (||) operator:

Stops evaluation upon finding one condition to be true.

Which of the following is false for pointer-based strings?

String literals are written inside of single quotes.

______is a communications protocol used to send information over the web.

TCP/IP

The array subscript operator [], when overloaded, cannot:

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

For a non-constant member function of class Test, the this pointer has type:

Test * const

The main difference between a pure virtual function and a virtual function is:

That a pure virtual function cannot have an implementation

An example of a unary operator is:

The ! logical operator.

To implicitly overload the += operator:

The += operator cannot be overloaded implicitly.

Which of the following operators cannot be overloaded?

The . operator.

Which of the following statements about the C++ Standard Library is false: *The C++ Standard Library consists of classes and functions that perform tasks. *An advantage of using classes and functions from the C++ Standard Library is saving the effort of designing, developing and testing new classes. *The C++ Standard Library is an important part of the C++ world. *The C++ Standard Library functions and classes are not included in every C++ implementation.

The C++ Standard Library functions and classes are not included in every C++ implementation.

To prevent modification of a built-in array's values when you pass the built-in array to a function:

The built-in array parameter can be preceded by the const qualifier

To prevent modification of a built-in array's values when you pass the built-in array to a function:

The built-in array parameter can be preceded by the const qualifier.

The compiler will implicitly create a default constructor if

The class does not define any constructors

Call-by-reference can achieve the security of call-by-value when

The const qualifier is used

Call-by-reference can achieve the security of call-by-value when:

The const qualifier is used

Call-by-reference can achieve the security of call-by-value when:

The const qualifier is used.

[C++11]: Which of the following is false?

The default range of a uniform_int_distribution is from 0 to 32767.

Which situation would require the operator to be overloaded as a non-member function?

The left operand is an int.

In a typical nested for loop (not a range-based for loop) used to process a two-dimensional array, following the end of each execution of the inner for loop:

The outer for loop increments its counter variable.

Which of the following does the C++ compiler not examine in order to select the proper overloaded function to call?

The return type of the function

Which of the following does the C++ compiler not examine in order to select the proper overloaded function to call?

The return type of the function.

If a variable is declared in the initialization expression of a for statement, then:

The scope of the variable is restricted to that for loop

An uninitialized local variable contains:

The value last stored in the memory location reserved for that variable

Which of the following statements about the Boost Libraries is false?

They are automatically included in the latest C++ Standard Library.

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.

Which of the following lines would be the prototype for an overloaded cast operator function that converts an object of user-defined type Time into a double?

Time::operator double() const;

Which of the following statement is true?

Two pointers that point to different built-in arrays cannot be compared meaningfully.

A variable that can have values only in the range 0 to 65535 is a

Two-byte unsigned int

A variable that can have values only in the range 0 to 65535 is a:

Two-byte unsigned int.

If the function int volume(int x = 1, int y = 1, int z = 1); is called by the expression volume(3), how many default arguments are used?

Two.

The rand function generates a data value of the type

Unsigned int

Parameterized stream manipulator setfill specifies the fill character that's displayed when an output is displayed in a field wider than the number of characters or digits in the output. The effect of setfill applies:

Until explicitly set to a different setting.

To rethrow an exception, the exception handler must:

Use the throw; statement.

Which of the following is a poor programming practice?

Using floating-point values for counters in counter-controlled iteration.

Which of the following is a poor programming practice?

Using floating-point values for counters in counter-controlled repetition

Which of the following statements is false?

Windows is an open source operating system.

Which statement about operator overloading is false?

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

Which of the following statements about the for statement is false?

You must declare the control variable before the for statement

Which of the following statements about a unique_ptr object is false?

You must explicitly delete the memory that's managed by a unique_ptr before the object goes out of scope.

A pointer should be initialized to _________ or ____________.

a nullptr, an integer

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

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

What will be the output after the following C++ statements have been executed? int a, b, c, d; a=4; b=12; c=37; d=51; if(a<b) cout<<"a<b"<<endl; if(a>b) cout<<"a>b"<<endl; if(d<=c) cout<<"d<=c"<<endl; if(c!=d) cout<<"c!=d"<<endl;

a<b c!=d

Which of the following does not declare a 2 by 2 array and set all 4 of its elements to 0?

all of the above initialize all 4 of the array elements to 0

What is the output of the following program? #include <iostream> using namespace std; int main() { int Set[8] = { 5, 10, 15, 20, 25, 30, 35, 40 }; int *Nums = Set; while ( Nums < &Set[7] ) { Nums--; cout << *Nums << " " ; } return 0; }

an endless loop occurs

Utility functions:

are private functions that support operations of the class's other member functions

An array's elements are related by the fact that they have the same ____________ and ______________.

array name, type.

Which of the following statement is declaring an array, fractions, with arraySize elements of type double, and initialize the elements to 0?

array<double, arraySize> fractions{0.0};

Which of the following is not a correct way to initialize the array named n?

array<int, 5> n{0, 7, 0, 3, 8, 2}; (number of values is greater than array size)

Lists and tables of values can be stored in _________ or __________ .

arrays, vectors

Float and double variables should be used

as approximated representations of decimal numbers

To use operators on class objects, they must be overloaded, with the exception of operators ________, __________ and __________.

assignment (=), address (&), comma (,)

The size, shape, color and weight of an object are considered __________ of the object's class.

attributes

Which of the following is most likely a base class of the other three?

automobile

Assuming that text is a variable of type string, what will be the contents of text after the statement cin >> text; is executed if the user types Hello World! then presses Enter? a."H" b."Hello" c."Hello World" d."Hello World!"

b."Hello"

Virtual destructors must be used when: a.The constructor in the base class is virtual. b.delete is used on a base-class pointer to a derived-class object. c.delete is used on a derived-class object. d.A constructor in either the base class or derived class is virtual.

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

Which of the following data items are arrange from the smallest to the largest in data heiracrch?

bit, characters, fields, records, files

Which of the following data items are arranged from the smallest to the largest in data hierarchy

bits, characters, fields, records, files

A default constructor:

both (a) and (b)

Which of the following is not one of the C++ control structures?

break

Which of the following is not a key organization in the open-source community? A.Apache B.SourceForge C.Firefox D.Eclipse

c

Which of the following will not increment c by 1?

c + 1;

An Algorithm that requires ____operations to complete its task on n data elements is said to have linear runtime: a. n^3 + 9 b. 3n^2+3n+2 c. 2n+1 d. 6

c. 2n+1

If the function in volume (int x = 1, int y = 1, int z = 1); is called by the expression volume(3), how many default arguments are used? a. None. b. One. c. Two. d. Three

c. Two.

The main difference between a pure virtual function and a virtual function is: a.The return type. b.The member access specifier. c.That a pure virtual function cannot have an implementation. d. The location in the class.

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

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

c.They do not remain virtual down the inheritance hierarchy.

Why are circular queues faster than standard vector-based queues?

circular queues don't require constant shifting and re-sizing unless specific circumstances arrive.

Every class definition contains the keyword ________ followed immediately by the class's name.

class

Which of the following statement is defining a constant variable arraySize to represent the size of an array and initialize it to 10?

const size_t arraySize{10};

When an object of a derived class is instantiated, the base class's _____________ is called implicitly or explicitly to do any necessary initialization of the base-class data members in the derived-class object.

constructor

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; }

constructor called, constructor called, destructor called, destructor called,

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; }

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:

count must be a non-const variable.

Given the following code, fill in the blank to call the function as described in the comment above it. #include <iostream> using namespace std; class Count { public: void setX( int value ) { x = value; } private: int x; } //end class Count int main() { Count counter; Count *counterPtr = &counter; Count &counterRef = counter; //set x to 2 using a reference to the object when calling the setX function ____________________________________;

counterRef.setX(2);

Which of the following does not display correct if answer is equal to 7 and incorrect if answer is not equal to 7?

cout << answer == 7 ? "correct" : "incorrect";

Which of the following does not perform the following task: Display correct if answer is equal to 7 and incorrect if answer is not equal to 7?

cout << answer == 7 ? "correct" : "incorrect";

Which of the following statement is using a for statement to display the elements of built-in array numbers using array subscript notation. Display each number with one digit to the right of the decimal point?

cout << fixed << showpoint << setprecision(1); for (size_t i{0}; i < size; ++i) { cout << numbers[i] << ' '; }

Which of the following statements restores the default fill character?

cout.fill(' ');

Which of the following prints the address of character string string given the following declaration? char* string{"test"};

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

Which of the following is not one of the three general types of computer language? a. machine languages b. assembly languages c.high-level languages d.spoken language

d.

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

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

Which of the following is a repetition structure?

do...while.

Class members are accessed via the __________ operator in conjunction with the name of an object (or reference to an object) of the class or via the ___________ operator in conjunction with a pointer to an object of the class

dot (.), arrow (->)

To call a member function for a specific object, you specify the object's name, followed by a(n) ________, then the member function name and a set of parentheses.

dot operator

Which of the following statement is declaring a built-in array of type double called numbers with 10 elements, and initialize the elements to the values 0.0, 1.1, 2.2, ..., 9.9? Assume that the constant size has been defined as 10.

double numbers[size]{0.0, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9};

Which of the following statement is declaring a pointer nPtr that points to a variable of type double?

double* nPtr;

Which of the following statement is assigning the address of variable number1 to pointer variable doublePtr? Assume that double variables number1 and number2 have been declared and that number1 has been initialized to 7.3.

doublePtr = &number1;

Which of the following is not a valid enumeration?

enum class Person {ME, YOU, ME};.

Which of the following for headers is not valid?

for ( int i = 0; int j = 5; ; i++ )

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?

for (int item : items) { cout <<item <<endl; }

Which of the following for headers is not valid?

for (int i{0}; int j{5}; ; i++)

Which of the following for headers produces the values from 27 through 3, decrementing by 3?

for (unsigned int i{27}; i >= 3; i -= 3)

A nonmember function must be declared by the class as a(n) ___________ of a class to have access to that class's private data members.

friend

Function _____________ from the <string> library reads characters until a newline character is encountered, then copies those characters into the specified string.

getline

In a(n) ______________ relationship, a class object has one or more objects of other classes as members.

has-a or composition or aggregation

In single inheritance, a class exists in a(n) __________ relationship with its derived classes.

hierarchical

The ________ statement is used to make decisions.

if

The expression if ( num!= 65 ) cannot be replaced by:

if ( !(num - 65) )

The expression if (num != 65) cannot be replaced by:

if (!(num - 65))

The selection statement ________________ is used to execute one action when a condition is true or a different action when that condition is false.

if...else

The selection statement ________________ is used to execute one action when a condition is true or a different action when that condition is false.

if...else.

The is-a relationship represents

inheritance

A constant object must be ___________; it cannot be modified after it's created.

initialized

Which of the following statements does not overwrite a preexisting value stored in a memory location?

int a;

Which statement would be used to declare a 10-element integer array c?

int c[10];

switch can be used to test:

int constants.

Which of the following uses C++11's list initialization to initialize count to 0?

int count{0};

Which of the following is not a correct way to initialize a built-in array?

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

Which of the following is a variable declaration statement?

int total;

Converting from type __ to type __ will result in the loss of data.

int, char

Converting from type ________ to type ________ will result in the loss of data.

int, char

A class's functions can throw exceptions, such as __________to indicate invalid data.

invalid_argument

A block:

is a compound statement

In a(n) ___________ relationship, an object of a derived class also can be treated as an object of its base class.

is-a or inheritance (for public inheritance)

A(n) ________ begins the body of every function and a(n) _________ ends the body.

left brace ({), right brace (}).

Which of the following is not included in <cmath>?

ln

Variables are also known as:

lvalues, but can be used as rvalues

Variables are also known as:

lvalues, but can be used as rvalues.

Every C++ program begins execution at the function _________ .

main

The ______ function allows characters of one part of a string to be copied into another, overlapping part of the same string.

memmove

Which of the following is not a valid C++ identifier?

my Value

Which is not a valid C++ identifier?

my Value (because of the space)

Keyword _______________ introduces an overloaded-operator function definition.

operator

[C++11]:Which of the following is not a keyword that was added to C++ in the new C++11 standard?

operator

Suppose a and b are integer variables and we form the sum a + b. Now suppose c and d are floating-point variables and we form the sum c + d. The two + operators here are clearly being used for different purposes. This is an example of __________________.

operator overloading

The correct function name for overloading the addition (+) operator is:

operator+

[C++11]:Which of the following is not a keyword that was added to C++ in the new C++11 standard?

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:

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

The std::endl stream manipulator________.

outputs a newline and flushes the output buffer.

The __________, __________ and _________ of an operator cannot be changed by overloading the operator.

precedence, associativity, "arity"

Class members specified as ___________ are accessible only to member functions of the class and friends of the class.

private

From most restrictive to least restrictive, the access modifiers are:

private, protected, public

When deriving a class from a protected base class, the public members of the base class become _________ and the protected members of the base class become __________?

protected, protected

When deriving from a class with protected inheritance, public members of the base class become ___________ members of the derived class, and protected members of the base class become ___________ members of the derived class.

protected, protected

A base class's ____________ members are accessible within that base class and anywhere that the program has a handle to an object of that class or one of its derived classes.

public

A base class's _________ and _____________ members can be accessed in the base-class definition, in derived-class definitions and in friends of the base class and derived classes.

public, protected

When deriving a class with public inheritance, public members of the base class become ___________ members of the derived class, and protected members of the base class become _____________ members of the derived class.

public, protected

Depending on the circumstances, the compiler may ignore the storage class specifier:

register

Two structure variables of the same type with the same member values, when compared will

result in a compile error

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?

s.operator!()

Which of the following is not one of the C++ control structures?

select

The ____________, __________ and ____________ are the only three forms of control necessary.

sequence, selection, iteration.

Which of the following expressions returns the trigonometric sine of x?

sin(x).

Which of the following gives the number of elements in the array int r[10]?

sizeof r / sizeof (int)

You can sort an array with the Standard Library's:

sort function.

You can sort an array with the Standard Library's:

sort functions

[C++11]: Given a built-in array of ints named values, which of the following statements would sort the array?

sort(begin(values), end(values));

The process of placing the elements of an array in order is called _______________ the array.

sorting.

Files ending in .cpp are known as ________ files.

source-code

The __ object enables a program to read data from the user

std::cin

Which of the following statements could potentially change the value of number2?

std::cin >> number2;

Which of the following statements would display the phrase C++ is fun?

std::cout << "Thisis fun\rC++ ";

Which of the following statements would display the phrase C++ is fun?

std::cout << "\"C++ is fun\"";

Which of the following code segments prints a single line containing hello there with the words separated by a single space?

std::cout<<"hello"; std::cout<<" there";

The OR ( | | ) operator:

stops evaluation upon finding one condition to be true

What is wrong with the following while loop? while (sum <= 1000) { sum = sum - 30; }

sum = sum - 30 should be sum = sum + 30 or else the loop may never end.

If a variable is declared in the initialization expression of a for statement, then:

the scope of the variable is restricted to that for loop

The main difference between functions atof, atoi, and atol is:

their return types

Comparing pointers and performing pointer arithmetic on them is meaningless unless:

they point to elements of the same array

An object's non-static member functions have access to a "self pointer" to the object called the _________ pointer.

this

When using exception handling, place any code that might throw an exception in a __________.

try statement

[C++11]: Which of the following statements creates a uniform_int_distribution object for producing values in the range -10 to 20?

uniform_int_distribution<int> randomInt{-10, 20};

At what point does a class' destructor get called?

when the constructor goes out of scope.

If x initially contains the value 3, which of the following sets x to 7?

x += 4;

Which of the following C++ statement is not adding 1 to integer variable x.?

x =+ 1;

Given the following command: int* my_array = (int * ) calloc (X, Y); Explain the what the input parameters x and y refer to

x refers to the number of elements to be allocated. y refers to the size of those elements.

For any nonzero 8-bit x, which of the following does not result in zero?

x |= x

Assuming that x and y are equal to 3 and 2, respectively, after the statement x-=y executes, the values of x and y will be:

x: 1; y: 2

In the expression n = x + rand () % y;

y is the scaling value

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?

y.operator+=(z)

Assuming that x is equal to 4, which of the following statements will not result in y containing the value 5 after execution?

y=x++

17.6 Q1: Which of the following is not a disadvantage of trying to modify a sequential access file?

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

A default constructor has how many parameters? a. 0 b. 1 c. 2 d. variable number

a. 0

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? a.Age. b.The President. c.Place of birth. d.Favorite food.

b.The President.

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: a.private b.virtual c.protected d. friend

b.virtual

Polymorphism is implemented via: a.Member functions. b.virtual functions and dynamic binding. c.inline functions. d.Non-virtual functions.

b.virtual functions and dynamic binding.

Static data members of a certain class: a. Can be accessed only if an object of that class exists. b. Cannot be changed, even by objects of the same that class c. Have class scope. d. Can only be changed by static member functions.

c. Have class scope.

Which of the following does the C++ compiler not examine in order to select the proper overloaded function to call? a. Types and order of the arguments in the function call b. The number of arguments in the function call. c. The return type of the function. d. It examines all of the above.

c. The return type of the function.

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? a.2003 b.2006 c.2012 d.2024

c.2012

Which of the following is a double-selection statement?

if...else.

Which of the following gives the number of elements in the array int r[ 10 ]?

sizeof r / sizeof ( int )

If x initially contains the value 3, which of the following sets x to 7?

x += 4;.

Assuming that x and y are equal to 3 and 2, respectively, after the statement x -= y executes, the values of x and y will be:

x: 1; y: 2.

A class-type attribute is best modeled by:

A composition association.

A fatal logic error can be caused by:

An attempt to divide by zero

17.3 Q1: Which of the following does not have a stream associated with it?

Answer: <iostream>.

17.2 Q1: Select the false statement.

Answer: A binary digit (bit) can store two values simultaneously.

17.2 Q4: In general, which of the following contains the most amount of data?

Answer: A database.

17.10 Q1: For an ifstream object A, a class type B and a local variable of type B called C, the proper way to read in one B object from A into C is:

Answer: A.read( reinterpret_cast< char * >( &C ), sizeof( B ) );.

17.7 Q1: Random access files are more effective than sequential files for:

Answer: All of the above.

17.2 Q2: Which statement is not true about 0, z , %, * and Q?

Answer: Only two of the elements listed are in typical character sets.

17.8 Q1: Select the false statement. The write function:

Answer: Writes to files in hexadecimal format.

17.5 Q1: 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.

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

17.11 Q1: Select the proper object type.__________ file( "file.dat", ios::in | ios::out);

Answer: fstream.

17.4 Q2: Which file open mode would be used to write data only to the end of an existing file?

Answer: ios::app.

17.3 Q3: Which of the following is not true about files?

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

17.5 Q2: What is not true about this code segment? location = fileObject.tellg();

Answer: location is a pointer.

17.9 Q1: Which of the following functions would not be used to write data randomly to a random access file?

Answer: tellg.

Which of the following is not a valid way to pass arguments to a function in C++?

By value with pointer arguments

Which of the following encompasses the other three?

Control structure.

A block:

Is a compound statement

Which of the following is not a piece of information that could be found in the attribute compartment of a class's rectangle in the UML?

The attribute's memory location.

Which of the following will not increment c by 1

c + 1;.

Attributes of a class are also known as: a. Constructor b.Local variables. c.Data members. d. Classes.

c. Data Members

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

c.Declaring an object to be const.

Which of the following does not perform the following task: print correct if answer is equal to 7 and incorrect if answer is not equal to 7?

cout << answer == 7 ? "correct" : "incorrect";

A constructor can specify the return type: a. int. b. string. c. void. d. A constructor cannot specify a return type.

d. A constructor cannot specify a return type.

If a set of functions have the same program logic and operations and differ only in the data type(s) each receives as argument(s) then a(n) __________ should be used. a.Overloaded function. b.Recursive function. c.Macro. d.Function template.

d.Function template.

Which forms of inheritance are is-a relationships? a.All forms of inheritance are is-a relationships. b.Only public and private. c.Only public and protected. d.Only public.

d.Only public.

What is wrong with the following while loop? while ( sum <= 1000 ) sum = sum - 30

sum = sum - 30 should be sum = sum + 30 or else the loop may never end.

What is the final value of x after performing the following operations? int x = 21; double y = 6; double z = 14; y = x / z; x = 5.5 * y

8

To handle situations where a loop must reinitialize a variable at the beginning of each iteration, such reinitialization could be performed by

A declaration inside the loop body.

Using a loop's counter-control variable in a calculation after the loop ends often causes a common logic error called:

An off-by-one error

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?

Pointer/offset notation

The Overloaded function must have: a. Different parameter list b. Different return type. c. The same number of parameters. d. The same number of default arguments

a. Different parameter list

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

a.In any order and multiple times.

In UML, the top compartment of the rectangle modeling a class contains: a.The class's name. b.The class's attributes. c.The class's behaviors. d. All of the above.

a.The class's name.

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(); a.Yes. b.Yes, if print is a static function. c.No. d.It would depend on the implementation of the print function.

a.Yes.

Static member functions: a. Can use this pointer. b. Can access only other static member functions and static data members. c. Cannot be called until an object of their class is instantiated. d. Can be declared const as well.

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

The is-a relationship represents: a. Composition b. Inheritance c. Information Hiding d. A friend

b. Inheritance

Which of the following assignments would be a compilation error? a.Assigning the address of a base-class object to a base-class pointer. b.Assigning the address of a base-class object to a derived-class pointer. c.Assigning the address of a derived-class object to a base-class pointer. d.Assigning the address of a derived-class object to a derived-class pointer.

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

Virtual functions must: a.Be overridden in every derived class. b.Be declared virtual in every derived class. c.Be declared virtual in the base class. d.Have the same implementation in every derived class.

b.Be declared virtual in every derived class.

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

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

A default constructor: a.Is a constructor that must receive no arguments. b.Is the constructor generated by the compiler when no constructor is provided by the programmer. c.Does not perform any initialization. d.Both (a) and (b).

b.Is the constructor generated by the compiler when no constructor is provided by the programmer.

Which of the following is not a kind of inheritance in C++? a. public b.private. c.static. d. protected.

c. static

The type of function a client would use to check the balance of a bank account would be a.A utility function. b.A predicate function. c.An access function. d A constructor.

c.An access function.

Every object of the same class: a.Gets a copy of every member function and member variable. b.Gets a copy of every member variable. c.Gets a copy of every member function. d. Shares pointers to all member variables and member functions.

c.Gets a copy of every member function.

[C++11]: Which of the following is true? a. The only way to define a constructor in a class is to explicitly define one. b. If you define any constructors with arguments, the compiler will also define a default constructor c.If you define any constructors with arguments, the compiler will not define a default constructor. d.You cannot explicitly create constructors.

c.If you define any constructors with arguments, the compiler will not define a default constructor.

What type of member functions allow a client of a class to assign values to private data members a.Client member functions. b.Get member functions. c.Set member functions. d. None of the above.

c.Set member functions.

The compiler will implicitly create a default constructor if: a. The class does not contain any data members. b.The programmer specifically requests that the compiler do so. c.The class does not define any constructors. d.The class already defines a default constructor.

c.The class does not define any constructors.

In the expression n = x + rand() % y; a.y is the shifting value. b.x is the scaling value. c.y is the scaling value. d.Both (a) and (b).

c.y is the scaling value.

Select the false statement regarding inheritance. a.A derived class can contain more attributes and behaviors than its base class. b.A derived class can be the base class for other derived classes. c.Some derived classes can have multiple base classes. d. Base classes are usually more specific than derived classes.

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

Which of the following is not a valid way to pass arguments to a function in C++? a.By reference with reference arguments. b.By value. c.By reference with pointer arguments. d. By value with pointer arguments.

d. By value with pointer arguments.

In regards to default arguments, which of the following is false? a. When an argument is omitted in a function call, the default value of that argument is automatically inserted by the compiler and passed in the function call. b. They must be the rightmost(trailing) arguments in a function's parameter list c. Default values can be constants. d. Default values cannot be global variables of function calls.

d. Default values cannot be global variables of function calls.

Which of the following is not a good example of a hierarchy likely to be modeled by inheritance? a.Airplanes. b.Geometric shapes. c.Animals. d. Prime numbers.

d. Prime numbers.

The given class definition: class CreateDestroy { public: CreateDestroy() {cout << "constructor called,";} ~CreateDestroy() {cout << "destructor called, " } }; what will the following program output? int main() { CreateDestroy c1; CreateDestroyc2; return 0; } a. constructor called, destructor called,constructor called, destructor called b.constructor called, destructor called, c.constructor called, constructor called, d. constructor called, constructor called, destructor called, destructor called,

d. constructor called, constructor called, destructor called, destructor called,

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? a.eat b.sleep c.move d.flap Wings

d.flap Wings

Specifying the order in which statements are to be executed in a computer program is called:

program control

Assuming that x is equal to 4, which of the following statements will not result in y containing the value 5 after execution?

y = x++;.


Conjuntos de estudio relacionados

Hearing Science Exam 3 - MSU - Franklin

View Set

Chapter 15 (Managing Quality and Performance)

View Set

Intro to Business Ch 8 Quiz (88%)

View Set

Illinois Real Estate Licensee Practice Questions

View Set

Medicare License Chapter 4 - Long-Term Care Policies

View Set

Macroecon Exam 3 - Quiz based (UofI)

View Set