41.
What happens when objects s1 and s2 are added?
string s1 = "Hello";
string s2 = "World";
string s3 = (s1+s2).substr(5);

42.
What does a mutable member of a class mean?

43.
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class test
{
    public:
    operator string () 
    {  
        return "Converted";
    }
};
int main()
{
    test t;
    string s = t;
    cout << s << endl;
    return 0;
}

44.
What will be the output of the following C++ code?
#include <iostream> 
#include <string>
#include <cstring>
using namespace std; 
int main()
{
	string s('a');
	cout<<s;
	return 0;
}

46.
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class sample;
class sample1 
{
    int width, height;
    public:
    int area ()
    {
        return (width * height);}
        void convert (sample a);
    };
class sample 
{
    private:
    int side;
    public:
    void set_side (int a)
    { 
        side = a;
    }
    friend class sample1;
};
void sample1::convert (sample a) 
{
    width = a.side;
    height = a.side;
}
int main () 
{
    sample sqr;
    sample1 rect;
    sqr.set_side(6);
    rect.convert(sqr);
    cout << rect.area();
    return 0;
}

50.
What will be the output of the following C++ code?
#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;
}

Read More Section(Classes and Objects in C plus plus)

Each Section contains maximum 100 MCQs question on Classes and Objects in C plus plus. To get more questions visit other sections.