1. The compareTo() function is used to ________________
Correct Answer is : Compare string object to another string object
2. String class provides function toUpper() to _____________________
Correct Answer is : Convert the whole string characters to uppercase
3. String trim() function is used to _______________________
Correct Answer is : Remove white space from both the ends of string
4. Function replace() accepts _____________ arguments.
5. If two arguments are passed to the indexOf() function then ___________________
Correct Answer is : Second argument indicates the occurrence number of specified character from starting
6. The string class deals with string of only character type.
7. A template class can have _____________
Correct Answer is : More than one generic data type
8. Which among the following is the proper syntax for the template class?
Correct Answer is : template T named(T x, T y){ }
9. Can default arguments be used with the template class?
Correct Answer is : Yes, always
10. What is the syntax to use explicit class specialization?
Correct Answer is : template class myClass{ }
11. Which is the most significant feature that arises by using template classes?
Correct Answer is : Code reusability
12. A template class defines the form of a class _____________________ it will operate.
Correct Answer is : Without full specification of the data on which
13. What are the two specializations of I/O template classes in C++?
Correct Answer is : 8-bit character and wide characters
14. Can typeid() function be used with the object of generic classes?
Correct Answer is : Yes, always
15. The _____________ class is a specialization of a more general template class.
Correct Answer is : String
16. How is function overloading different from template class?
Correct Answer is : Overloading is multiple function doing similar operation, Template is multiple function doing identical operations
17. What if static members are declared inside template classes?
Correct Answer is : All instances will have their own static variable
18. What is the output of following program?
template
void test(const T&x)
{
static int count = 0;
cout << "x = " << x << " count = " << count << endl;
++count;
return;
}
void main()
{
test (2);
test(2);
test(2.2);
}
Correct Answer is : x = 2 count = 0
19. If template class is defined, is it necessary to use different types of data for each call?
Correct Answer is : No, not necessary
20. How many generic types can be given inside a single template class?
Correct Answer is : As many as required