52.
What will be the output of the following C++ code?
#include <iostream>
#include <cstring>
using namespace std;
int main ()
{
    char str1[10] = "Hello";
    char str2[10] = "World";
    char str3[10];
    int  len ;
    strcpy( str3, str1);
    strcat( str1, str2);
    len = strlen(str1);
    cout << len << endl;
    return 0;
}

53.
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class Box{
    int capacity;
public:
    Box(){}
    Box(double capacity){
	this->capacity = capacity;
    }
    bool operator<(Box b){
	return b.capacity < this->capacity? true : false;
    }
};
int main(int argc, char const *argv[])
{
    Box b1(10);
    Box b2 = Box(14);
     if(b1 < b2){
	cout<<"B1's capacity is small";
    }
    else{
	cout<<"B2's capacity is small";
    }
    return 0;
}

55.
Pick out the correct statement.

59.
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class complex
{
    int i;
    int j;
    public:
    complex(){}
    complex(int a, int b)
    {
	i = a;
	j = b;
    }
    complex operator+(complex c)
    {
	complex temp;
	temp.i = this->i + c.i;
	temp.j = this->j + c.j;
	return temp;
    }
 void operator+(complex c)
    {
	complex temp;
	temp.i = this->i + c.i;
	temp.j = this->j + c.j;
	temp.show_poss();
    }
 void show(){
    cout<<"Complex Number: "<<i<<" + i"<<j<<endl;
    }
 void show_poss(){
    cout<<"Your result after addition will be: "<<i<<" + i"<<j<<endl;
    }
};
int main(int argc, char const *argv[])
{
    complex c1(1,2);
    complex c2(3,4);
    c1 + c2;
    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.