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

Discuss
Answer: (a).Standard error stream
Discuss
Answer: (c).Deriving a derived class from more than one base class
Q13.
Which symbol is used to create multiple inheritance?
Discuss
Answer: (b).Comma
Q14.
Which of the following advantages we lose by using multiple inheritance?
Discuss
Answer: (c).Both Dynamic binding & Polymorphism
Q15.
What is the output of this program?
    #include <iostream>
    using namespace std;
    class polygon 
    {
        protected:
        int width, height;
        public:
        void set_values (int a, int b)
        { 
            width = a; height = b;}
        };
        class output1 
        {
            public:
                void output (int i);
        };
    void output1::output (int i) 
    {
        cout << i << endl;
    }
    class rectangle: public polygon, public output1 
    {
        public:
        int area ()
        { 
            return (width * height); 
        }
    };
    class triangle: public polygon, public output1 
    {
        public:
        int area ()
        {
            return (width * height / 2); 
        }
    };
    int main () 
    {
        rectangle rect;
        triangle trgl;
        rect.set_values (4, 5);
        trgl.set_values (4, 5);
        rect.output (rect.area());
        trgl.output (trgl.area());
        return 0;
    }
Discuss
Answer: (c).20
Q16.
What is the output of this program?
    #include <iostream>
    using namespace std;
    class Base
    {
        public:
        virtual void print() const = 0;
    };
    class DerivedOne : public Base
    {
        public:     
        void print() const
        {
            cout << "DerivedOne\n";
        }
    };
    class DerivedTwo : public Base
    {
        public:
        void print() const
        {
            cout << "DerivedTwo\n";
        }     
    }; 
    class Multiple : public DerivedOne, public DerivedTwo
    {
        public:
        void print() const
        {
            DerivedTwo :: print();
        } 
    }; 
    int main()
    {
        int i;
        Multiple both; 
        DerivedOne one; 
        DerivedTwo two; 
        Base *array[ 3 ]; 
        array[ 0 ] = &both; 
        array[ 1 ] = &one;
        array[ 2 ] = &two;
        array[ i ] -> print();
        return 0;
    }
Discuss
Answer: (c).Error
Q17.
What is the output of this program?
    #include <iostream>
    using namespace std;
    class student
    {
        public:
        int rno , m1 , m2 ;
        void get()
        {
            rno = 15, m1 = 10, m2 = 10;
        }
    };
    class sports
    {
        public:
        int sm;
        void getsm()
        {
            sm = 10;
        }
    };
    class statement:public student,public sports
    {
        int tot,avg;
        public:
        void display()
        {
            tot = (m1 + m2 + sm);
            avg = tot / 3;
            cout << tot;
            cout << avg;
        }
    };
    int main()
    {
        statement obj;
        obj.get();
        obj.getsm();
        obj.display();
    }
Discuss
Answer: (b).3010
Q18.
What is the output of this program?
    #include <iostream>
    using namespace std;
    struct a
    {
        int count;
    };
    struct b
    {
        int* value;
    };
    struct c : public a, public b
    {
    };
    int main()
    {
        c* p = new c;
        p->value = 0;
        cout << "Inherited";
        return 0;
    }
Discuss
Answer: (a).Inherited
Q19.
What is the output of this program?
    #include <iostream>
    using namespace std;
    class Base1
    {
        protected:
        int SampleDataOne;
        public:
        Base1()
        {
            SampleDataOne = 100;
        }
        ~Base1()
        {
        }
        int SampleFunctOne()
        {
            return SampleDataOne;
        }
    };
    class Base2
    {
        protected:
        int SampleDataTwo;
        public:
        Base2()
        {
            SampleDataTwo = 200;
        }
        ~Base2()
        {
        }
        int SampleFunctTwo()
        {
            return SampleDataTwo;
        }
    };
    class Derived1 : public Base1, public Base2
    {
        int MyData;
        public:
        Derived1() 
        {
            MyData = 300;
        }
        ~Derived1()
        {
        }    
        int MyFunct()
        {
            return (MyData + SampleDataOne + SampleDataTwo);
        }
    };
    int main()
    {
        Base1 SampleObjOne;
        Base2 SampleObjTwo;
        Derived1 SampleObjThree;
        cout << SampleObjThree.Base1 :: SampleFunctOne() << endl;
        cout << SampleObjThree.Base2 :: SampleFunctTwo() << endl;
        return 0;
    }
Discuss
Answer: (c).Both 100 & 200
Q20.
Which design patterns benefit from the multiple inheritance?
Discuss
Answer: (a).Adapter and observer pattern
Page 2 of 15

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!