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 8 of 15

Discuss
Answer: (a).Contains the standard exception files
Q72.
How many sets of requirements are need in designing a container?

a.

1

b.

2

c.

3

d.

4

Discuss
Answer: (c).3
Q73.
Which interface in the container is required for storage management?
Discuss
Answer: (b).Allocater interface
Q74.
Which is present in the basic interface of the allocator interface?
Discuss
Answer: (d).All of the mentioned
Q75.
What is the output of this program?
    #include <iostream>
    #include <vector>
    using namespace std;
    class Component
    { 
        public:
        virtual void traverse() = 0;
    };
    class Leaf: public Component
    {
        int value;
        public:
        Leaf(int val)
        {
            value = val;
        }
        void traverse()
        {
            cout << value << ' ';
        }
    };
    class Composite: public Component
    {
        vector < Component * > children;
        public:
        void add(Component *ele)
        {
            children.push_back(ele);
        }
        void traverse()
        {
            for (int i = 0; i < children.size(); i++)
                children[i]->traverse();
        }
    };
    int main()
    {
        Composite containers[4];
        for (int i = 0; i < 4; i++)
            for (int j = 0; j < 3; j++)
                containers[i].add(new Leaf(i *3+j));
            for (int k = 1; k < 4; k++)
                containers[0].add(&(containers[k]));
            for (int p = 0; p < 4; p++)
            {
                containers[p].traverse();
            }
    }
Discuss
Answer: (d).None of the mentioned
Q76.
Which container provides random access iterators?
Discuss
Answer: (d).both vector & deque
Q77.
What is the output of this program?
    #include <iostream>
    #include <vector>
    #include <iterator>
    #include <stddef.h>
    using namespace std;
    template<class myType>
    class SimpleContainer
    {
        public:
        SimpleContainer(size_t xDim, size_t yDim, myType const& defaultValue)
        : objectData(xDim * yDim, defaultValue)
        , xSize(xDim)
        , ySize(yDim)
        {
        }
        myType& operator()(size_t x, size_t y)
        {
            return objectData[y * xSize + x];
        }
        myType const& operator()(size_t x, size_t y) const 
        {
            return objectData[y * xSize + x];
        }
        int getSize()
        {
            return objectData.size();
        }
        void inputEntireVector(vector<myType> inputVector)
        {
            objectData.swap(inputVector);
        }
        void printContainer(ostream& stream)
        {
            copy(objectData.begin(), objectData.end(),
            ostream_iterator<myType>(stream, ""/*No Space*/));
        }
        private:
        vector<myType> objectData;
        size_t  xSize;
        size_t  ySize;
    };
    template<class myType>
    inline ostream& operator<<(ostream& stream, SimpleContainer<myType>& object)
    {
        object.printContainer(stream);
        return stream;
    }
    void sampleContainerInterfacing();
    int main()
    {
        sampleContainerInterfacing();
        return 0;
    }
    void sampleContainerInterfacing()
    {
        static int const ConsoleWidth  = 80;
        static int const ConsoleHeight = 25;
        size_t width  = ConsoleWidth;
        size_t height = ConsoleHeight;
        SimpleContainer<int> mySimpleContainer(width, height, 0);
        cout << mySimpleContainer.getSize() << endl;
        mySimpleContainer(0, 0) = 5;
    }
Discuss
Answer: (d).Depends on the compiler
Q78.
Which is used for manually writing lookup table?
Discuss
Answer: (a).std:map
Q79.
How the member functions in the container can be accessed?
Discuss
Answer: (a).Iterator
Q80.
Which of the following type does the container should define?
Discuss
Answer: (a).Iterator type

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!