Questions and Answers


  1. To what type of object does the container can be instantiated?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    any type of object


  1. What type of class template is list?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    It is node-based because it allows efficient insertion anywhere on the program.



  1. 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;
    }











  1. 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.


  1. 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;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: E

    In this program, We are counting the number of elements in the map.



  1. What is the lifetime of the element in container?











  1. 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.