A second opinion would be much appreciated on the following C++ questions: QUEST
ID: 3826232 • Letter: A
Question
A second opinion would be much appreciated on the following C++ questions:
QUESTION 1
Which of the following is not a valid enumeration statement?
A. Enum person { me, you, them };.
B. Enum person { me = 1, you = 2, them = 3 };.
C. Enum person { me = 0, you = 0, them = 0 };.
D. Enum person { me, you, me };.
QUESTION 2
Class string has member function __________ to interchange the data stored in two string objects
exchange
switch
swap
copyto
QUESTION 4
Enumeration constants:
Must have unique integer values.
Can be assigned other values once they've been defined.
Must have unique identifiers.
Are declared using the keyword const.
QUESTION 5
If string s1 is lexicographically greater than string s2, then the value returned by s2.compare(0, s2.size(), s1) must be?
0
-1
A negative number
A positive number
QUESTION 6
If string s contains "antidisestablishmentarianism", then s.substr( 7, 13 ) would be:
"establish"
"ishmenta"
"establi"
"establishment"
QUESTION 7
Which of the following returns a bool?
length
empty
capacity
resize
QUESTION 8
Which of the following is not an argument of the assign member function?
The start location.
The number of characters to copy.
The end location.
The string to copy.
QUESTION 9
If string s1 has the value "computer" and string s2 has the value "promise", which call to insert will produce the string "compromise"?
s1.insert( 4, s2, 0, string::npos );
s1.insert( string::npos, s2, 0, 4 );
s2.insert( 0, s1, 0, 3 );
s2.insert( 3, s1, 0, 3 );
QUESTION 10
Which of the following cannot be used to concatenate strings?
+
+=
append
assign
QUESTION 11
Which of the following is an invalid definition?
string sa = "computers";
string sb( "computers" );
string sc( 'c' );
string sd( 9, 'c' );
QUESTION 12
The arguments passed to replace do not include:
The subscript of the element where the replace operation ends.
The subscript of the element where the replace operation begins.
A replacement character string from which a substring is used to replace characters.
The element in the replacement character string where the replacement substring begins.
QUESTION 13
Given the strings defined below, which statement will not return 0?
string s1 = "Mighty Mouse";
string s2 = "Mickey Mouse";
s1.compare( 0, 3, s2, 0, 3 );
s1.compare( 7, 5, s2, 7, 5 );
s1.compare( 8, 12, s2, 8, 12 );
s1.compare( 7, 11, s2, 7, 11 );
QUESTION 14
The function call string1.erase( 5 ) will:
Return a copy of string1 minus the character that occupied position 5.
Erase all characters up to and including the character in position 5 from string1.
Erase all characters starting from and including the character in position 5 to the end of string1.
Return a copy of string1 minus every fifth character.
QUESTION 15
Which of the following would not return string::npos when used on the string s which contains "rack":
s.find_first_not_of( "crackling" );
s.find_first_not_of( "packrat" );
s.rfind( "car" );
s.find( "ack" );
QUESTION 16
Which of the following searches through a string object from right-to-left?
find
find_first_of
find_last_of
find_first_not_of
-Thank you.
A.exchange
B.switch
C.swap
D.copyto
Explanation / Answer
QUESTION 1:
Which of the following is not a valid enumeration statement?
D. Enum person { me, you, me }
Explanation:
you can't define previously definned name in enumerations..
You will get error when you declare like this num person { me, you, me };
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.