CPP

CPP

Almost Containers has 10 Questions
What kind of library is Standard Template Library?

Polymorphic
Generic
Both a & b
None of the mentioned
To what type of object does the container can be instantiated?

int
float
double
Any type of object
What type of access does deque and vector provide?

Linear access
Parallel access
Random access
None of the mentioned
Which are not full container classes in c++?

Sequence container
Associative container
Container adaptor
None of the mentioned
What type of class template is list?

Class-based
Node-based
Method-based
None of the mentioned
What is the lifetime of the element in container?

Whole program
Outside the block
Everywhere
Only on that container
What is the output of this program?
  1.     #include 
  2.     #include  
  3.     using namespace std;
  4.     int main ()
  5.     {
  6.         multimap<char, int> mymultimap;
  7.         mymultimap.insert(make_pair('x', 100));
  8.         mymultimap.insert(make_pair('y', 200));
  9.         mymultimap.insert(make_pair('y', 350));
  10.         mymultimap.insert(make_pair('z', 500));
  11.         cout << mymultimap.size() << '\n';
  12.         return 0;
  13.     }

1
2
4
3
What is the output of this program?
  1.     #include 
  2.     #include 
  3.     using namespace std;
  4.     int main ()
  5.     {
  6.         priority_queue<int> mypq;
  7.         mypq.push(10);
  8.         mypq.push(20);
  9.         mypq.push(15);
  10.         cout  << mypq.top() << endl;
  11.         return 0;
  12.     }

15
20
10
Error
What is the output of this program?
  1.     #include 
  2.     #include 
  3.     using namespace std;
  4.     int main ()
  5.     {
  6.         multimap<char, int> mymultimap;
  7.         mymultimap.insert(make_pair('y', 202));
  8.         mymultimap.insert(make_pair('y', 252));
  9.         pair<char, int> highest = *mymultimap.rbegin();
  10.         multimap<char, int> :: iterator it = mymultimap.begin();
  11.         do 
  12.         {
  13.             cout << (*it).first << " => " << (*it).second << '\n';
  14.         } while ( mymultimap.value_comp()(*it++, highest) );
  15.         return 0;
  16.     }

y =%gt; 202
y =%gt; 252
Both a & b
None of the mentioned
Where does the vector add the item?

End
Insert
Middle
None of the mentioned