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

Explore more Topics under Object Oriented Programming Using C++

Discuss
Answer: (a).Compile-time construct
Discuss
Answer: (b).Non-static members of class objects
Q43.
What should be used to point to a static class member?
Discuss
Answer: (c).Normal pointer
Q44.
Which operator is used in pointer to member function?
Discuss
Answer: (c).Both .* & ->*
Q45.
What is the output of this program?
    #include <iostream>
    using namespace std;
    class X 
    {
        public:
        int a;
  void f(int b) 
  {
   cout<< b << endl;
  }
    };
    int main() 
    {
        int X :: *ptiptr = &X :: a;
        void (X :: * ptfptr) (int) = &X :: f;
        X xobject;
        xobject.*ptiptr = 10;
        cout << xobject.*ptiptr << endl;
        (xobject.*ptfptr) (20);
    }
Discuss
Answer: (a).10 20
Q46.
What is the output of this program?
    #include <iostream>
    using namespace std;
    class Testpm 
    {
        public:
        void m_func1() 
        { 
            cout << "func1\n";
        }
        int m_num;
    };
    void (Testpm :: *pmfn)() = &Testpm :: m_func1;
    int Testpm :: *pmd = &Testpm :: m_num;
    int main() 
    {
        Testpm ATestpm;
        Testpm *pTestpm = new Testpm;
        (ATestpm.*pmfn)();
        (pTestpm ->* pmfn)();
        ATestpm.*pmd = 1;
        pTestpm ->* pmd = 2;
        cout << ATestpm.*pmd << endl
        << pTestpm ->* pmd << endl;
    }
Discuss
Answer: (d).func1 func1 1 2
Q47.
What is the output of this program?
    #include <iostream>
    using namespace std;
    class Car
    {
        public:
        int speed;
    };
    int main()
    {
        int Car :: *pSpeed = &Car :: speed;
        Car c1;
        c1.speed = 1;           
        cout << c1.speed << endl;
        c1.*pSpeed = 2;     
        cout  << c1.speed << endl;
        return 0;
    }
Discuss
Answer: (c).Both 1 & 2
Q48.
What is the output of this program?
    #include <iostream>
    using namespace std;
    class bowl 
    {
        public:
        int apples;
        int oranges;
    };
    int count_fruit(bowl * begin, bowl * end, int bowl :: *fruit)
    {
        int count = 0;
        for (bowl * iterator = begin; iterator != end; ++ iterator)
            count += iterator ->* fruit;
        return count;
    }
    int main()
    {
        bowl bowls[2] = {{ 1, 2 },{ 3, 5 }};
        cout << "I have " << count_fruit(bowls, bowls + 2, & bowl :: apples) << " apples\n";
        cout << "I have " << count_fruit(bowls, bowls + 2, & bowl :: oranges) << " oranges\n";
        return 0;
    }
Discuss
Answer: (a).I have 4 apples I have 7 oranges
Q49.
What is the output of this program?
    #include <iostream>
    using namespace std;
    class Foo
    {
        public:
        Foo(int i = 0){ _i = i;}
        void f()
        {
            cout << "Executed"<<endl;
        }
        private:
        int _i;
    };
    int main()
    {
        Foo *p = 0;
        p -> f();
    }
Discuss
Answer: (a).Executed
Q50.
Which is the best design choice for using pointer to member function?
Discuss
Answer: (a).Interface

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!