21. Pick the incorrect statement about Character-Array.
22. What will be the output of the following C++ code?
#include <stdio.h>
#include<iostream>
using namespace std;
int main()
{
int x = 5, y = 5, z;
x = ++x; y = --y;
z = x++ + y--;
cout << z;
return 0;
}
#include <stdio.h>
#include<iostream>
using namespace std;
int main()
{
int x = 5, y = 5, z;
x = ++x; y = --y;
z = x++ + y--;
cout << z;
return 0;
}23. What will be the output of the following C++ code?
#include <stdio.h>
#include<iostream>
using namespace std;
int main()
{
int num1 = 5;
int num2 = 3;
int num3 = 2;
num1 = num2++;
num2 = --num3;
cout << num1 << num2 << num3;
return 0;
}
#include <stdio.h>
#include<iostream>
using namespace std;
int main()
{
int num1 = 5;
int num2 = 3;
int num3 = 2;
num1 = num2++;
num2 = --num3;
cout << num1 << num2 << num3;
return 0;
}24. Which of the following is correct way of concatenating two string objects in C++?
way 1:
string s1 = "hello";
string s2 = "world";
string s3 = s1 + s2;
way 2:
string s1 = "hello";
string s2 = "world";
string s3 = s1.append(s2);
way 3:
string s1 = "hello";
string s2 = "world";
string s3 = strcat(s1,s2);
way 1:
string s1 = "hello";
string s2 = "world";
string s3 = s1 + s2;
way 2:
string s1 = "hello";
string s2 = "world";
string s3 = s1.append(s2);
way 3:
string s1 = "hello";
string s2 = "world";
string s3 = strcat(s1,s2);25. What does the data type defined by union will do?
26. What is the name of | operator?
27. In which direction does the assignment operation will take place?
28. Which category of data type a class belongs to?
29. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class sample
{
private:
int a, b;
public:
void test()
{
a = 100;
b = 200;
}
friend int compute(sample e1);
};
int compute(sample e1)
{
return int(e1.a + e1.b) - 5;
}
int main()
{
sample e;
e.test();
cout << compute(e);
return 0;
}
#include <iostream>
using namespace std;
class sample
{
private:
int a, b;
public:
void test()
{
a = 100;
b = 200;
}
friend int compute(sample e1);
};
int compute(sample e1)
{
return int(e1.a + e1.b) - 5;
}
int main()
{
sample e;
e.test();
cout << compute(e);
return 0;
}30. Which operator works only with integer variables?
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.
