Professional Documents
Culture Documents
Chapter 7
Chapter 7
a. True
b. False
ANSWER: True
POINTS: 1
REFERENCES: 469
QUESTION TYPE: True / False
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:40 PM
DATE MODIFIED: 10/5/2016 1:40 PM
Chapter 7
7. The following statement creates an anonymous type:
Chapter 7
DATE CREATED: 10/5/2016 1:40 PM
DATE MODIFIED: 10/5/2016 1:40 PM
The statement:
Chapter 7
ANSWER: b
POINTS: 1
REFERENCES: 474
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:40 PM
DATE MODIFIED: 10/5/2016 1:40 PM
16. In C++, you can create aliases to a previously defined data type by using the ____ statement.
a. typedef b. using
c. namespace d. alias
ANSWER: a
POINTS: 1
REFERENCES: 477
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
Chapter 7
DATE CREATED: 10/5/2016 1:40 PM
DATE MODIFIED: 10/5/2016 1:40 PM
Chapter 7
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:40 PM
DATE MODIFIED: 10/5/2016 1:40 PM
namespace globalType
{
void printResult();
}
22. Which of the following statements is used to simplify the accessing of all globalType namespace members?
a. using globalType;
b. using namespace globalType:all;
c. using namespace globalType::all;
d. using namespace globalType;
ANSWER: d
POINTS: 1
REFERENCES: 488-489
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:40 PM
DATE MODIFIED: 10/5/2016 1:40 PM
23. The identifiers in the system-provided header files such as iostream, cmath, and iomanip are defined in the
namespace ____.
a. cctype b. stdl
c. std d. stdlib
ANSWER: c
POINTS: 1
REFERENCES: 492
Copyright Cengage Learning. Powered by Cognero. Page 7
Name: Class: Date:
Chapter 7
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:40 PM
DATE MODIFIED: 10/5/2016 1:40 PM
24. Before using the data type string, the program must include the header file ____.
a. enum b. iostream
c. string d. std
ANSWER: c
POINTS: 1
REFERENCES: 492
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:40 PM
DATE MODIFIED: 10/5/2016 1:40 PM
25. Suppose str = "xyzw";. After the statement str[2] = 'Y'; The value of str is "____".
a. xyzw b. xYzw
c. xyYw d. xzYw
ANSWER: c
POINTS: 1
REFERENCES: 493
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:40 PM
DATE MODIFIED: 10/5/2016 1:40 PM
26. Suppose that str1, str2, and str3 are string variables. After the following statements execute, the value of
str3 is "____".
str1 = "abc";
str2 = "xyz";
str3 = str1 + '-' + str2;
a. abc b. xyz
c. abc-xyz d. xyz-abc
ANSWER: c
POINTS: 1
REFERENCES: 493
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:40 PM
DATE MODIFIED: 10/5/2016 1:40 PM
27. The data type string has a named constant, ____, associated with it.
Copyright Cengage Learning. Powered by Cognero. Page 8
Name: Class: Date:
Chapter 7
a. string::size b. string::size_type
c. string::pos d. string::npos
ANSWER: d
POINTS: 1
REFERENCES: 496
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:40 PM
DATE MODIFIED: 10/5/2016 1:40 PM
is ____.
a. 7 b. 8
c. 9 d. 10
ANSWER: c
POINTS: 1
REFERENCES: 498
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:40 PM
DATE MODIFIED: 10/5/2016 1:40 PM
After the statement position = str.find('D'); executes, the value of position is ____.
a. 3 b. 4
c. 6 d. 7
Copyright Cengage Learning. Powered by Cognero. Page 9
Name: Class: Date:
Chapter 7
ANSWER: a
POINTS: 1
REFERENCES: 500
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:40 PM
DATE MODIFIED: 10/5/2016 1:40 PM
31. Considering the statement string str = "Gone with the wind";, the output of the statement cout <<
str.find("the") << endl; is ____.
a. 9 b. 10
c. 11 d. 12
ANSWER: b
POINTS: 1
REFERENCES: 500
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:40 PM
DATE MODIFIED: 10/5/2016 1:40 PM
After the statement str2 = str1.substr(1,4); executes, the value of str2 is "____".
a. ABCD b. BCDE
c. BCD d. CDE
ANSWER: b
POINTS: 1
REFERENCES: 503-504
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:40 PM
DATE MODIFIED: 10/5/2016 1:40 PM
33. The ____ function is used to interchange the contents of two string variables.
a. iterator b. traverse
c. swap d. change
ANSWER: c
POINTS: 1
REFERENCES: 505
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
Copyright Cengage Learning. Powered by Cognero. Page 10
Name: Class: Date:
Chapter 7
DATE CREATED: 10/5/2016 1:40 PM
DATE MODIFIED: 10/5/2016 1:40 PM
After the statement str2 = str1.substr(5,4); executes, the value of str2 is "____".
a. Gone b. with
c. the d. wind
ANSWER: b
POINTS: 1
REFERENCES: 503-504
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:40 PM
DATE MODIFIED: 10/5/2016 1:40 PM
35. The values in the domain of an enumeration type are called ____________________.
ANSWER: enumerators
POINTS: 1
REFERENCES: 469
QUESTION TYPE: Completion
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:40 PM
DATE MODIFIED: 10/5/2016 1:40 PM
36. A data type wherein you directly specify values in the variable declaration with no type name is called a(n)
____________________type.
ANSWER: anonymous
POINTS: 1
REFERENCES: 477
QUESTION TYPE: Completion
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:40 PM
DATE MODIFIED: 10/5/2016 1:40 PM
37. In ANSI/ISO Standard C++, the ____________________ mechanism was designed to solve the problem of
overlapping global identifiers.
ANSWER: namespace
POINTS: 1
REFERENCES: 487
QUESTION TYPE: Completion
HAS VARIABLES: False
Copyright Cengage Learning. Powered by Cognero. Page 11
Name: Class: Date:
Chapter 7
DATE CREATED: 10/5/2016 1:40 PM
DATE MODIFIED: 10/5/2016 1:40 PM
38. If a global identifier in a program has the same name as one of the global identifiers in the header file, the compiler
generates a(n) ____________________ error.
ANSWER: syntax
POINTS: 1
REFERENCES: 487
QUESTION TYPE: Completion
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:40 PM
DATE MODIFIED: 10/5/2016 1:40 PM
39. The string expression strVar.____________________ inserts all the characters of str at index pos into
strVar.
ANSWER: insert(pos, str);
POINTS: 1
REFERENCES: 497
QUESTION TYPE: Completion
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:40 PM
DATE MODIFIED: 10/5/2016 1:40 PM
40. The string expression strVar.____________________ starts at index pos, replaces the next n characters of
strVar with all the characters of str.
ANSWER: strVar.replace(pos, n, str);
POINTS: 1
REFERENCES: 497
QUESTION TYPE: Completion
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:40 PM
DATE MODIFIED: 10/5/2016 1:40 PM