Filters
Question type

Study Flashcards

The C++ compiler performs strict array bounds checking whenever an array of characters is being accessed.

Correct Answer

verifed

verified

The following statement declares a string object and initializes it to "Once upon a time". string theString("Once upon a time");

Correct Answer

verifed

verified

True

Assume that str1 and str2 are objects of the string class. The proper expression to use when comparing them for equality is


A) str1 = str2.
B) str1 == str2.
C) strcmp(str1, str2) .
D) str1.compare(str2) .
E) None of the above

Correct Answer

verifed

verified

Which statements convert the string "10" to the integer value 10?


A) istringstream istr("10") ; int x; istr >> x;
B) ostringstream ostr("10") ; int x; ostr >> x;
C) int x = stoi("10") ;
D) int x = str("10") :
E) None of the above

Correct Answer

verifed

verified

The expression strcmp("ab", "cde") returns


A) the boolean value false.
B) the boolean value True.
C) a negative integer.
D) a nonnegative integer.
E) None of the above

Correct Answer

verifed

verified

By being able to pass arrays as arguments, you can write your own functions for processing C-strings.

Correct Answer

verifed

verified

The strcpy function's arguments are


A) two string class objects.
B) two pointers to char.
C) three pointers.
D) three arrays and one pointer.
E) None of the above

Correct Answer

verifed

verified

The string class overloads the += operator to perform


A) conversion to integers followed by addition.
B) concatenation of two strings.
C) calculation of the sum of the integer ASCII codes that comprise the characters in the string.
D) calculation of the sum of the lengths of two strings.
E) None of the above

Correct Answer

verifed

verified

Although C++ provides ample library functions to handle numeric values, we must write all of our own functions to manipulate character values.

Correct Answer

verifed

verified

To declare a C-string, you should use the type expression string *.

Correct Answer

verifed

verified

False

The expression str1 < str 2 is True when


A) the string object str1 precedes the string str 2 in alphabetic order.
B) the string str1 converted to numeric form is less than the string str2 converted to numeric form.
C) the length of the string str1 is less than the length of the string str2.
D) the C-string "str1" precedes the C-string "str2" in alphabetic order.
E) None of the above

Correct Answer

verifed

verified

The string class member function ________ returns the C-string value of the string object.


A) c_string(string s)
B) c_str(string s)
C) c_str()
D) c_string()
E) None of the above

Correct Answer

verifed

verified

Assume that str1 and str2 are variables of type C-string. The proper expression to use when comparing them for equality is


A) str1 = str2.
B) str1 == str2.
C) strcmp(str1, str2) == 0.
D) str1.compare(str2) .
E) None of the above

Correct Answer

verifed

verified

The proper expression to compare the first characters of two string objects str1 and str2 is


A) str1[0] = str2[0].
B) str1[0] == str2[0].
C) strcmp(str1[0], str2[0]) .
D) 'str1[0]' == 'str2[0]'.
E) None of the above

Correct Answer

verifed

verified

B

A good way to convert a value of type double to a string is


A) use the ostringstream class.
B) use the strtodouble function.
C) use the doubletoa function.
D) use the doublestringstream class.
E) None of the above

Correct Answer

verifed

verified

To account for the null terminator stored at the end of each C-string, the strlen function returns the number of characters in its argument, plus one.

Correct Answer

verifed

verified

The string class member function ________ will return the number of characters in the string object.


A) length()
B) length(string s)
C) capacity()
D) capacity(string s)
E) None of the above

Correct Answer

verifed

verified

The string class append member function str.append(s)tacks a string s to the end of str.

Correct Answer

verifed

verified

The code int x = 0; while (s[x] != 0) { x++;}


A) sets the variable x to point to the last character in the C-string s.
B) computes the length of the C-string s into the variable x.
C) sets the variable x to the ASCII code of the last character in the C-string s.
D) sets the value of the variable x to 0.
E) None of the above

Correct Answer

verifed

verified

The >> operator can be used to convert a value of type double to an equivalent string object stored in memory.

Correct Answer

verifed

verified

Showing 1 - 20 of 40

Related Exams

Show Answer