Professional Documents
Culture Documents
C++ Programming From Problem Analysis To Program Design 6th Edition Malik Test Bank 1
C++ Programming From Problem Analysis To Program Design 6th Edition Malik Test Bank 1
Chapter 7: User-Defined Simple Data Types, Namespaces, and the string Type
TRUE/FALSE
MULTIPLE CHOICE
The statement:
a. FORD c. TOYOTA
b. GM d. HONDA
ANS: B PTS: 1 REF: 453-455
a. ALGEBRA c. 1
b. 0 d. "ALGEBRA"
ANS: B PTS: 1 REF: 458
6. In C++, you can create aliases to a previously defined data type by using the ____ statement.
a. typedef c. namespace
b. using d. alias
ANS: A PTS: 1 REF: 461
namespace globalType
{
void printResult();
}
13. 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;
ANS: D PTS: 1 REF: 472-473
14. The identifiers in the system-provided header files such as iostream, cmath, and iomanip are
defined in the namespace ____.
a. cctype c. std
b. stdl d. stdlib
ANS: C PTS: 1 REF: 476
15. Before using the data type string, the program must include the header file ____.
a. enum c. string
b. iostream d. std
ANS: C PTS: 1 REF: 476
16. Suppose str = "xyzw";. After the statement str[2] = 'Y'; The value of str is
"____".
a. xyzw c. xyYw
b. xYzw d. xzYw
ANS: C PTS: 1 REF: 477-478
17. 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 c. abc-xyz
b. xyz d. xyz-abc
ANS: C PTS: 1 REF: 477-479
18. The data type string has a named constant, ____, associated with it.
a. string::size c. string::pos
b. string::size_type d. string::npos
ANS: D PTS: 1 REF: 480
is ____.
a. 7 c. 9
b. 8 d. 10
ANS: C PTS: 1 REF: 482
22. Considering the statement string str = "Gone with the wind";, the output of the
statement cout << str.find("the") << endl; is ____.
a. 9 c. 11
b. 10 d. 12
ANS: B PTS: 1 REF: 484
After the statement str2 = str1.substr(1,4); executes, the value of str2 is "____".
Another document from Scribd.com that is
random and unrelated content:
International donations are gratefully accepted, but we cannot make any
statements concerning tax treatment of donations received from outside
the United States. U.S. laws alone swamp our small staff.
Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of other
ways including checks, online payments and credit card donations. To
donate, please visit: www.gutenberg.org/donate.
Most people start at our website which has the main PG search facility:
www.gutenberg.org.