Questions and Answers
- To what type of object does the container can be instantiated?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
any type of object
- What type of class template is list?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
It is node-based because it allows efficient insertion anywhere on the program.
- What is the output of this program?
#include <iostream>
#include <queue>
using namespace std;
int main ()
{
priority_queue<int> QueueData;
QueueData.push(12);
QueueData.push(25);
QueueData.push(13);
cout << QueueData.top() << endl;
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
In this program, We used the queue template and the top method is used to retain the last but before element.
- What is the output of this program?
#include <iostream>
#include <map>
using namespace std;
int main ()
{
multimap<char, int> MultimapData;
MultimapData.insert(make_pair('P', 150));
MultimapData.insert(make_pair('Q', 250));
MultimapData.insert(make_pair('Q', 300));
MultimapData.insert(make_pair('R', 450));
cout << MultimapData.size() << '\n';
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: E
In this program, We are counting the number of elements in the map.
- What is the lifetime of the element in container?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
A Container “owns” its elements: the lifetime of an element stored in a container cannot exceed that of the Container itself.