adplus-dvertising

Welcome to the Classes and Operator Overloading in C++ MCQs Page

Dive deep into the fascinating world of Classes and Operator Overloading in C++ with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Classes and Operator Overloading in C++, 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 Classes and Operator Overloading in C++, 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 Classes and Operator Overloading in C++. 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 Classes and Operator Overloading in C++. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Classes and Operator Overloading in C++ MCQs | Page 5 of 39

Explore more Topics under Object Oriented Programming Using C++

Q41.
Which of these following members are not accessed by using direct member access operator?
Discuss
Answer: (d).both private & protected
Q42.
What is the output of the following program?
    #include <iostream>
    using namespace std;
    class Box
    {
        public :
        double length;
        double breadth;
        double height;
    };
    int main( )
    {
        Box Box1;
        double volume;
        Box1.height = 5;
        Box1.length = 6;
        Box1.breadth = 7.1;
        volume = Box1.height * Box1.length * Box1.breadth;
        cout << "Volume of Box1 : " << volume <<endl;
        return 0;
    }
Discuss
Answer: (b).213
Q43.
What is the output of the program?
    #include <iostream>
    using namespace std;
    class Rect
    {
        int x, y;
        public:
        void set_values (int,int);
        int area ()
        {
            return (x * y);
        }
    };
    void Rect::set_values (int a, int b) 
    {
        x = a;
        y = b;
    }
    int main ()
    {
        Rect recta, rectb;
        recta.set_values (5, 6);
        rectb.set_values (7, 6);
        cout << "recta area: " << recta.area();
        cout << "rectb area: " << rectb.area();
        return 0;
    }
Discuss
Answer: (a).recta area: 30 rectb area: 42
Discuss
Answer: (d).instance of the class
Q45.
How many objects can present in a single class?
Discuss
Answer: (d).as many as possible
Q46.
What is the output of this program?
    #include <iostream>
    using namespace std;
    class sample
    {
        private:
        int var;
        public:
        void input()
        {
           cout << var;
        }
        void output()
        {
           cout << "Variable entered is ";
           cout << var << "\n";
        }
    };
    int main()
    {
        sample object;
        object.input();
        object.output();
        object.var();
        return 0;
    }
Discuss
Answer: (c).Error
Q47.
Which special character is used to mark the end of class?

a.

;

b.

:

c.

#

d.

$

Discuss
Answer: (a).;
Q48.
What is the output of this program?
    #include <iostream>
    using namespace std;
    class number
    {
        int i;
        public:
        int geti();
        void puti(int j);
    };
    int number::geti()
    {
        return i;
    }
    void number::puti(int j)
    {
        i = j;
    }
    int main()
    {
        number s;
        s.puti(10);
        cout << s.geti( );
        return 0;
    }
Discuss
Answer: (a).10
Discuss
Answer: (b).operator overloading
Q50.
Which of the following operators can’t be overloaded?
Discuss
Answer: (a).::

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!