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

Explore more Topics under Object Oriented Programming Using C++

Q21.
What are the things are inherited from the base class?
Discuss
Answer: (d).All of the mentioned
Q22.
How many access specifiers are there in c++?

a.

1

b.

2

c.

3

d.

4

Discuss
Answer: (c).3
Discuss
Answer: (c).The variable is visible to its block and to it’s derived class
Q24.
To which of the following access aspecifiers are applicable?
Discuss
Answer: (c).Both Member data & Functions
Q25.
What is the output of this program?
    #include <iostream>
    using namespace std;
    class student
    {
        public:
        int rno , m1 , m2 ;
        protected:
        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;
        }
        void setObject()
        {
            get();
        }
    };
    int main()
    {
        statement obj;
        obj.setObject();
        obj.getsm();
        obj.display();
    }
Discuss
Answer: (a).3010
Q26.
What is the output of this program?
    #include <iostream>
    using namespace std; 
    struct A 
    {
        int i;
        char j;
        float f;
        void func();
    };
    void A :: func() {}
    struct B 
    {
        public:
        int i;
        char j;
        float f;
        void func();
    };
    void B :: func() {}
    int main() 
    {
        A a; B b;
        a.i = b.i = 1; 
        a.j = b.j = 'c';
        a.f = b.f = 3.14159;
        a.func();
        b.func();
        cout << "Allocated"; 
        return 0;
    }
Discuss
Answer: (a).Allocated
Q27.
What is the output of this program?
    #include <iostream>
    using namespace std;
    struct A 
    {
        private:
        int i, j, k;
        public:
        int f();
        void g();
    };
    int A :: f() 
    {
        return i + j + k;
    }
    void A :: g() 
    {
        i = j = k = 0;
    }
    class B 
    {
        int i, j, k;
        public:
        int f();
        void g();
    };
    int B :: f() 
    {
        return i + j + k; 
    }
    void B :: g() 
    {
        i = j = k = 0;
    }
    int main() 
    {
        A a;
        B b;
        a.f(); 
        a.g();
        b.f(); 
        b.g();
        cout << "Identical results would be produced";
    }
Discuss
Answer: (b).Identical results would be produced
Q28.
What is the output of this program?
    #include <iostream>
    using namespace std;
    class Cat
    {
        public:
        int age;
        int weight;
    };
    int main()
    {
        Cat f;
        f.age = 56;
        cout << "Gates is " ;
        cout << f.age << " years old.\n";
    }
Discuss
Answer: (b).Gates is 56 years old
Q29.
What is the output of this program?
    #include <iostream>
    using namespace std;
    struct X;
    struct Y 
    {
        void f(X*);
    };
    struct X 
    {
        private:
        int i;
        public:
        void initialize(); 
        friend void g(X* , int);
        friend void Y :: f(X*);
        friend struct Z;
        friend void h();
    };
    void X :: initialize() 
    {
        i = 0;
    }
    void g(X* x, int i) 
    {
        x -> i = i;
    }
    void Y :: f(X * x) 
    {
        x -> i = 47;
        cout << x->i;
    }
    struct Z 
    {
        private:
        int j;
        public:
        void initialize();
        void g(X* x);
    };
    void Z::initialize() 
    {
        j = 99;
    }
    void Z::g(X* x) 
    {
        x -> i += j;
    }
    void h() 
    {
        X x;
        x.i = 100;
        cout << x.i;
    }
    int main() 
    {
        X x;
        Z z;
        z.g(&x);
        cout << "Data accessed";
    }
Discuss
Answer: (c).Data accessed
Q30.
What is the default access level to a block of data?
Discuss
Answer: (c).Private

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!