Q: Which is an instantiation of the basic_string class template?
Solution: The string class is an instantiation of the basic_string class template.
Q: Which character is used to terminate the string?
Solution: A string of characters is stored in successive elements of a character array are terminated by the NULL character.
Q: How does the strings are stored in the memory?
Solution: The characters of a string are stored contiguously in the memory.
Q: Where are the strings stored?
Solution: Dynamic strings(dynamic length) are stored in heap and static string(with fixed size) are stored in stack.
Q: What will happen if a string is empty?
Solution: An empty string is a character array with the NULL character in the zeroth index position.
Q: Which header file is used to manipulate the string?
Solution: To use the string class, We have to use #includeheader file.
Q: How many maximum number of parameters does a string constructor can take?
Solution: string(other_string, position, count). It is a type of constructor for the string.
Q: Which constant member functions does not modify the string?
Solution: Because bool empty is a constant member function, So it can’t be modified.
Q: What is the difference between unsigned int length() and unsigned int size()?
Solution: Both of them will return the length of strings in the same notations.
Q: How many parameters can a resize method take?
Solution: There can be one or two parameters in resize method. They are string length and an optional new character to be inserted.
You Have Score    | /10 |