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.
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
A. | exchange | |
B. | switch | |
C. | swap | |
D. | copyto |
QUESTION 4
Enumeration constants:
A. | Must have unique integer values. | |
B. | Can be assigned other values once they've been defined. | |
C. | Must have unique identifiers. | |
D. | 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?
A. | 0 | |
B. | -1 | |
C. | A negative number | |
D. | A positive number |
QUESTION 6
If string s contains "antidisestablishmentarianism", then s.substr( 7, 13 ) would be:
A. | "establish" | |
B. | "ishmenta" | |
C. | "establi" | |
D. | "establishment" |
QUESTION 7
Which of the following returns a bool?
A. | length | |
B. | empty | |
C. | capacity | |
D. | resize |
QUESTION 8
Which of the following is not an argument of the assign member function?
A. | The start location. | |
B. | The number of characters to copy. | |
C. | The end location. | |
D. | 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"?
A. | s1.insert( 4, s2, 0, string::npos ); | |
B. | s1.insert( string::npos, s2, 0, 4 ); | |
C. | s2.insert( 0, s1, 0, 3 ); | |
D. | s2.insert( 3, s1, 0, 3 ); |
QUESTION 10
Which of the following cannot be used to concatenate strings?
A. | + | |
B. | += | |
C. | append | |
D. | assign |
QUESTION 11
Which of the following is an invalid definition?
A. | string sa = "computers"; | |
B. | string sb( "computers" ); | |
C. | string sc( 'c' ); | |
D. | string sd( 9, 'c' ); |
QUESTION 12
The arguments passed to replace do not include:
A. | The subscript of the element where the replace operation ends. | |
B. | The subscript of the element where the replace operation begins. | |
C. | A replacement character string from which a substring is used to replace characters. | |
D. | 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";
A. | s1.compare( 0, 3, s2, 0, 3 ); | |
B. | s1.compare( 7, 5, s2, 7, 5 ); | |
C. | s1.compare( 8, 12, s2, 8, 12 ); | |
D. | s1.compare( 7, 11, s2, 7, 11 ); |
QUESTION 14
The function call string1.erase( 5 ) will:
A. | Return a copy of string1 minus the character that occupied position 5. | |
B. | Erase all characters up to and including the character in position 5 from string1. | |
C. | Erase all characters starting from and including the character in position 5 to the end of string1. | |
D. | 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":
A. | s.find_first_not_of( "crackling" ); | |
B. | s.find_first_not_of( "packrat" ); | |
C. | s.rfind( "car" ); | |
D. | s.find( "ack" ); |
QUESTION 16
Which of the following searches through a string object from right-to-left?
A. | find | |
B. | find_first_of | |
C. | find_last_of | |
D. | find_first_not_of |
-Thank you.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started