C++ Programming Multiple Choice Questions & Answers (MCQs) on “STL Container Any – 1”.
1. What is any in C++?
a) STL container used to store a single value of any type
b) Exception class in C++
c) Fundamental type provided by C++
d) Template data type
Answer: a
Clarification: Any is an STL container provided by C++ to store value or objects of any type.
2. In how many different ways any-container can be constructed?
a) 1
b) 2
c) 3
d) 4
Answer: c
Clarification: There are three basic ways of constructing any variable. They are done using copy initialization, using the constructor or using an assignment operator.
3. What is the correct syntax of constructing any using copy initialization?
a) any variable_name = value;
b) any variable_name(value);
c)
any variable_name; variable_name = value;
d) any
Answer: a
Clarification: To initialize an any variable using copy initialization we use the following syntax:
any variable_name = value;
4. What is the correct syntax of constructing any using parameterized constructor?
a) any variable_name = value;
b) any variable_name(value);
c)
any variable_name; variable_name = value;
d) any
Answer: b
Clarification: To initialize an any variable using parameterized constructor we use the following syntax:
any variable_name(value);