You can prepare effectively for Class 10 C++ Programming for Beginners with this dedicated MCQ Practice Test (available with solutions) on the important topic of "Test: C++ Strings". These 15 questions have been designed by the experts with the latest curriculum of Class 10 2026, to help you master the concept.
Test Highlights:
Sign up on EduRev for free to attempt this test and track your preparation progress.
Detailed Solution: Question 1
How many maximum number of parameters does a string constructor can take?
Detailed Solution: Question 2
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str;
string str2="Steve jobs";
string str3="He founded apple";
str.append(str2);
str.append(str3, 6, 3);
str.append(str3.begin() + 6, str3.end());
str.append(5,0x2e);
cout << str << '\n';
return 0;
}
Detailed Solution: Question 3
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str ("I like to code in C");
unsigned sz = str.size();
str.resize (sz + 2, '+');
str.resize (14);
cout << str << '\n';
return 0;
}
Detailed Solution: Question 4
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string name ("Jobs");
string family ("Steve");
name += " Apple ";
name += family;
name += '\n';
cout << name;
return 0;
}
Detailed Solution: Question 5
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str ("Steve jobs founded the apple");
string str2 ("apple");
unsigned found = str.find(str2);
if (found != string :: npos)
cout << found << '\n';
return 0;
}
Detailed Solution: Question 6
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str ("Steve jobs");
cout << str.length();
return 0;
}
Detailed Solution: Question 7
What will be the output of the following C++ code?
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
int main ()
{
string str ("Steve jobs");
char * cstr = new char [str.length() + 1];
strcpy (cstr, str.c_str());
char * p = strtok (cstr," ");
while (p != 0)
{
cout << p << '\n';
p = strtok(NULL," ");
}
delete[] cstr;
return 0;
}
Detailed Solution: Question 8
Detailed Solution: Question 9
Detailed Solution: Question 10
Detailed Solution: Question 11
Detailed Solution: Question 12
Detailed Solution: Question 13
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str ("Test string");
for ( string :: iterator it = str.begin(); it != 5; ++it)
cout << *it;
return 0;
}
Detailed Solution: Question 14
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str ("Steve jobs");
cout << str.capacity() << "\n";
return 0;
}
Detailed Solution: Question 15
15 videos|20 docs|13 tests |