MCQs
Total Questions : 10
Answer: Option A. -> access is public by default
None.
Answer: Option A. -> initalize the objects
Once the object is declared means, the constructor are also declared by default.
Answer: Option B. -> private
None.
Answer: Option A. -> class A { int x; };
None.
Question 5.
1.
#include
2.
using namespace std;
3.
class CDummy
4.
{
5.
public:
6.
int isitme (CDummy& param);
7.
};
8.
int CDummy::isitme (CDummy& param)
9.
{
10.
if (¶m == this)
11.
return true;
12.
else
13.
return false;
14.
}
15.
int main ()
16.
{
17.
CDummy a;
18.
CDummy *b = &a;
19.
if (b->isitme(a)) {
20.
cout << "execute";
21.
}
22.
else
23.
{
24.
cout<<"not execute";
25.
}
26.
return 0;
27.
}
What is the output of this program?
1.
#include
2.
using namespace std;
3.
class CDummy
4.
{
5.
public:
6.
int isitme (CDummy& param);
7.
};
8.
int CDummy::isitme (CDummy& param)
9.
{
10.
if (¶m == this)
11.
return true;
12.
else
13.
return false;
14.
}
15.
int main ()
16.
{
17.
CDummy a;
18.
CDummy *b = &a;
19.
if (b->isitme(a)) {
20.
cout << "execute";
21.
}
22.
else
23.
{
24.
cout<<"not execute";
25.
}
26.
return 0;
27.
}
Answer: Option A. -> execute
In this program, we are just pointing the pointer to a object and printing execute if it is correctly pointed.
Output:
$ g++ class1.cpp
$ a.out
execute
Answer: Option B. -> rect area: 12
In this program, we are calculating the area of rectangle based on given values.
Output:
$ g++ class.cpp
$ a.out
rect area: 12
Answer: Option B. -> ::
None.
Answer: Option D. -> both a & b
Struct and union take the same definition of class but differs in the access techniques.
Answer: Option C. -> both a & b
The classes in c++ are used to manipulate both data and functions.
Answer: Option C. -> 3
There are three types of access specifiers. They are public, protected and private.