1. Which is an instantiation of the basic_string class template?
a) Character
b) String class
c) Memory
d) None of the mentioned
2. Which character is used to terminate the string?
a) $
b) Null
c) Empty
d) None of the mentioned
3. How does the strings are stored in the memory?
a) Contiguous
b) Non-contiguous
c) Null
d) All of the mentioned
4. What is the output of this program?
a) Steve jobs
b) He founded apple
c) Steve
d) None of the mentioned
5. What is the output of this program?
a) Test
b) string
c) Test string
d) Error
6. What is the output of this program?
a) Steve Jobs
b) Apple
c) Jobs Apple Steve
d) None of the mentioned
7. What is the output of this program?
a) Jobs the apple
b) the apple
c) Steve
d) Jobs
8. What is the output of this program?
a) 8
b) 10
c) 12
d) 9
9. In which format does the strings are stored?
a) Stack
b) Heap
c) Both a & b
d) None of the mentioned
10. What will happen if a string is empty?
a) It can’t be created
b) Raises an error
c) It can be used
d) None of the mentioned
a) Character
b) String class
c) Memory
d) None of the mentioned
2. Which character is used to terminate the string?
a) $
b) Null
c) Empty
d) None of the mentioned
3. How does the strings are stored in the memory?
a) Contiguous
b) Non-contiguous
c) Null
d) All of the mentioned
4. What is the output of this program?
#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<int>(5, 0x2E);
cout << str << '\n';
return 0;
}
b) He founded apple
c) Steve
d) None of the mentioned
5. What is the output of this program?
#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;
}
b) string
c) Test string
d) Error
6. What is the output of this program?
#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;
}
b) Apple
c) Jobs Apple Steve
d) None of the mentioned
7. What is the output of this program?
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str="Steve Jobs founded the apple";
string str2 = str.substr (6, 4);
unsigned pos = str.find("the");
string str3 = str.substr (pos);
cout << str2 << ' ' << str3 << '\n';
return 0;
}
b) the apple
c) Steve
d) Jobs
8. What is the output of this program?
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str ("Steve jobs");
cout << str.length();
return 0;
}
b) 10
c) 12
d) 9
9. In which format does the strings are stored?
a) Stack
b) Heap
c) Both a & b
d) None of the mentioned
10. What will happen if a string is empty?
a) It can’t be created
b) Raises an error
c) It can be used
d) None of the mentioned