String MCQ Questions
String MCQ Questions
- string s;
- String s;
- char s[];
- All of the above
Answer: All of the above
Q11: What is the output of this code: string s = "Hello"; cout << s[1];
- H
- e
- l
- o
Answer: e
Q13: Which function returns the position of the first occurrence of a substring?
- find()
- indexOf()
- search()
- match()
Answer: find()
Q14: What is the return type of the compare() function in C++ string?
- bool
- int
- string
- void
Answer: int
Q15: How can you get the last character of a string s in C++?
- s[s.length()-1]
- s.back()
- s.at(s.size()-1)
- All of the above
Answer: All of the above