C++ Unit 7 Test: User-Defined Simple Data Types
Which of the following statements is FALSE? a. In C++, strings are enclosed in single quotation marks. b. Relational operators can be applied to the string type. c. The assignment operator can be used with the string type. d. A string is a sequence of zero or more characters.
a. In C++, strings are enclosed in single quotation marks.
In C++, [ ] is called the _____ operator. a. array subscript b. array c. character d. array index
a. array subscript
If a global identifier in a program has the same name as a global identifier in an included header file, the ____. a. compiler generates a syntax error b. global identifier in the program overrides the global identifier in the header file c. global identifier in the header file overrides the global identifier in the program d. compiler automatically generates a new name for the global identifier in the program
a. compiler generates a syntax error
A using statement is typically placed ____. a. directly after the namespace declaration b. with the variable declarations in main c. in the function in which the namespace members are used d. directly before the namespace declaration
a. directly after the namespace declaration
Which of the following functions is used to delete all of the characters in a string? a. erase b. delete c. empty d. remove
a. erase
An enumeration type is a set of ____ values. a. ordered b. anonymous c. unordered d. constant
a. ordered
You can access an individual character within a string using the array subscript operator together with the ____. a. position of the character in the string b. the integer equivalent of the character value c. value of the character in single quotes d. value of the character in double quotes
a. position of the character in the string
Which of the following is not a string function? a. resize b. find c. empty d. size
a. resize
You can simplify the accessing of namespace members with the ____ statement. a. using b. typedef c. define d. include
a. using
The operator ____ can be used to concatenate two values of type string. a. & b. + c. - d. ::
b. +
You can use the ____ operator to increment or decrement the value of an enumeration type. a. stream b. cast c. scope resolution d. assignment
b. cast
The syntax for an enumeration type is ____. a. enum typeName [value1, value2, ...] b. enum typeName {value1, value2, ...} c. enum typeName (value1, value2, ...) d. enum {value1, value2, ...} typeName
b. enum typeName {value1, value2, ...}
The enumeration type is a(n) ____ type. a. Boolean b. character c. integral d. string
c. integral
The ____ function is used to interchange the contents of two string variables. a. substr b. switch c. swap d. change
c. swap
The _____ statement does not create any new data type; it creates only an alias to an existing data type. a. namespace b. using c. typedef d. enum
c. typedef
Before using the data type string, the program must use which of the following statements to include the header file? a. #include <cstring> b. include <#string> c. #include (cstring) d. #include <string>
d. #include <string>
The position of the first character in a string starts at ____. a. 1 b. the ending position of the last string used in the program c. a user-defined position d. 0
d. 0
ANSI/ISO Standard C++ was approved in ____. a. 1988 b. 2001 c. 1981 d. 1998
d. 1998
The values that you specify for an enumeration type must be _____. a. true or false b. reserved words c. sorted d. identifiers
d. identifiers
The scope of a namespace is ____. a. global to all namespaces in the same directory b. global to the C++ library c. undefined d. local to the namespace
d. local to the namespace