adplus-dvertising

Welcome to the Class Hierarchies,Library and Containers MCQs Page

Dive deep into the fascinating world of Class Hierarchies,Library and Containers with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Class Hierarchies,Library and Containers, a crucial aspect of Object Oriented Programming Using C++. In this section, you will encounter a diverse range of MCQs that cover various aspects of Class Hierarchies,Library and Containers, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within Object Oriented Programming Using C++.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Class Hierarchies,Library and Containers. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of Object Oriented Programming Using C++.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Class Hierarchies,Library and Containers. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Class Hierarchies,Library and Containers MCQs | Page 10 of 15

Q91.
Which is optional in the declaration of vector?
Discuss
Answer: (d).Number_of_elements
Q92.
How many items are there in sequence container?

a.

2

b.

3

c.

4

d.

5

Discuss
Answer: (d).5
Q93.
Which of the following class template are based on arrays?
Discuss
Answer: (d).both vector & dequeue
Q94.
Which of the following will return the new element at the end of container?
Discuss
Answer: (b).back
Q95.
What is the output of this program?
    #include <iostream>
    #include <deque>
    using namespace std;
    int main ()
    {
        deque<int> mydeque (5);  
        deque<int>::reverse_iterator rit = mydeque.rbegin();
        int i = 0;
        for (rit = mydeque.rbegin(); rit!= mydeque.rend(); ++rit)
            *rit = ++i;
        for (deque<int> :: iterator it = mydeque.begin();
        it != mydeque.end(); ++it)
        cout << ' ' << *it;
        return 0;
    }
Discuss
Answer: (c).54321
Q96.
What is the output of this program?
    #include <iostream>
    #include <deque>
    using namespace std;
    int main ()
    {
        unsigned int i;
        deque<int> a (3,100);
        deque<int> b (5,200);
        a.swap(b);
        cout << "a contains:";
        for (deque<int>::iterator it = a.begin(); it != a.end(); ++it)
            cout << ' ' << *it;
        cout << "b contains:";
        for (deque<int>::iterator it = b.begin(); it != b.end(); ++it)
            cout << ' ' << *it;
        return 0;
    }
Discuss
Answer: (a).a contains: 200 200 200 200 200b contains: 100 100 100
Q97.
What is the output of this program?
    #include <iostream>
    #include <deque>
    using namespace std;
    int main ()
    {
        unsigned int i;
        deque<int> mydeque;
        mydeque.push_back (100);
        mydeque.push_back (200);
        mydeque.push_back (300);
        for(deque<int> :: iterator it = mydeque.begin(); it != mydeque.end(); ++it)
        {
        }
        mydeque.clear();
        mydeque.push_back (110);
        mydeque.push_back (220);
        for(deque<int> :: iterator it = mydeque.begin(); it != mydeque.end(); ++it)
            cout << ' ' << *it;
        cout << '\n';
        return 0;
    }
Discuss
Answer: (c).Both 110 & 220
Q98.
What is the output of this program?
    #include <iostream>
    #include <vector>
    using namespace std;
    int main ()
    {
        vector<int> myvector;
        int * p;
        unsigned int i;
        p = myvector.get_allocator().allocate(5);
        for (i = 0; i < 5; i++) 
            myvector.get_allocator().construct(&p[i], i);
        for (i = 0; i < 5; i++)
            cout << ' ' << p[i];
        for (i = 0; i < 5; i++)
            myvector.get_allocator().destroy(&p[i]);
        myvector.get_allocator().deallocate(p, 5);
        return 0;
    }
Discuss
Answer: (b).0 1 2 3 4
Q99.
What is the output of this program?
    #include <iostream>
    #include <cmath>
    #include <list>
    using namespace std;
    bool same_integral_part (double first, double second)
    {  
        return ( int(first) == int(second) ); 
    }
    struct is_near 
    {
        bool operator() (double first, double second)
        { 
            return (fabs(first - second) < 5.0); 
        }
    };
    int main ()
    {
        double mydoubles[] = { 12.15,  2.72, 73.0,  12.77,  3.14, 12.77, 73.35, 72.25, 15.3,  72.25 };
        list<double> mylist (mydoubles, mydoubles + 10);
        mylist.sort();
        mylist.unique();
        mylist.unique (same_integral_part);
        mylist.unique (is_near());
        for (list<double> :: iterator it = mylist.begin(); it != mylist.end(); ++it)
            cout << ' ' << *it;
        cout << '\n';
        return 0;
    }
Discuss
Answer: (a).2.72 12.15 72.25
Discuss
Answer: (a).Using Double linked list

Suggested Topics

Are you eager to expand your knowledge beyond Object Oriented Programming Using C++? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!