1.
What does STL stand for?

(a) Simple Template Library
(b) Standard Template Library
(c) Static Type Library
(d) Single Type¬based Library

Answer
(b) STL stands for Standard Template Library

2.
STL is based on which of the following programming paradigms?

(a) Structured Programming
(b) Object Oriented Programming (OOP)
(c) Functional Programming
(d) Aspect Oriented Programming (AOP)

Answer
(c) Functional Programming

3.
Which of the STL containers store the elements contiguously (in adjecent memory locations)?

(a) std::vector
(b) std::list
(c) std::map
(d) std::set

Answer
(d) std::set

4.
Find the output of this:
#include
using namespace std;
main()
{
char s= “hello”,
t = “hello”;
if (s = = t)
Cout<<“equal strings”;
}
(a) Equal strings
(b)Unequal strings
(c) No output
(d) Compilation error

Answer
(c) No output, as we are comparing both base addresses and are not same.

5.
What kind of iteration does forward_list provide in C++?

(a) Uni-directional
(b) Bi-directional
(c) Multi-directional
(d) None of the mentioned

Answer
(a) In the forward_list, the container provides insertion and removal at anywhere in the program.

6.
What does the size of the vector refers to in c++?

(a) Size of vector
(b) Type of vector
(c) Number of elements
(d) None of the mentioned

Answer
(d) none.

7.
What is the use of adapter in STL in c++?

(a) To provide interface
(b) To manipulate the data
(c) To extract the data
(d) None of the mentioned

Answer
(a) Adapters are data types from STL that adapt a container to provide specific interface.

8.
What is the output of this program?

#include
#include
using namespace std;
int main ()
{
Vector < int > myvector;
myvector.push_back (78);
myvector.push_back (16);
myvector. Front () += myvector. Back ();
Cout << myvector. Front () << ‘\n’;
return 0;
}

(a) 78
(b) 16
(c) 94
(d) None of the mentioned

Answer
(c)
In this program, we added all the values in the vector by using front and back operation.
Output:
$ g++ seqc1.cpp
$ a.out
94.

9.
Which is used to iterate over container?

(a) Associated iterator type
(b) Data type of objects
(c) Return type of variables
(d) None of the mentioned

Answer
(a) None

10.
Which is not C++ storage class

(a) auto
(b) register
(c) static
(d) iostream

Answer
(d)
Storage classes are:

auto
register
static
extern

Standard Template Library (STL)
Tagged on: