1. What does your class can hold?
a) data
b) functions
c) both a & b
d) none of the mentioned
2. How many specifiers are present in access specifiers in class?
a) 1
b) 2
c) 3
d) 4
3. Which is used to define the member of a class externally?
a) :
b) ::
c) #
d) none of the mentioned
4. Which other keywords are also used to declare the class other than class?
a) struct
b) union
c) object
d) both a & b
5. What is the output of this program?
a) rect area:12
b) rect area: 12
c) rect area:24
d) none of the mentioned
6. What is the output of this program?
a) execute
b) not execute
c) none of the mentioned
d) both a & b
7. Which of the following is a valid class declaration?
a) class A { int x; };
b) class B { }
c) public class A { }
d) object A { int x; };
8. The fields in the class in c++ program are by default
a) protected
b) private
c) public
d) none of the mentioned
9. Constructors are used to
a) initalize the objects
b) construct the data members
c) both a & b
d) none of the mentioned
10. When struct is used instead of the keyword class means, what will happen in the program?
a) access is public by default
b) access is private by default
c) access is protected by default
d) none of the mentioned
a) data
b) functions
c) both a & b
d) none of the mentioned
Answer:c
2. How many specifiers are present in access specifiers in class?
a) 1
b) 2
c) 3
d) 4
Answer:c
3. Which is used to define the member of a class externally?
a) :
b) ::
c) #
d) none of the mentioned
Answer:b
4. Which other keywords are also used to declare the class other than class?
a) struct
b) union
c) object
d) both a & b
Answer:d
5. What is the output of this program?
#include <iostream>
using namespace std;
class rect
{
int x, y;
public:
void val (int, int);
int area ()
{
return (x * y);
}
};
void rect::val (int a, int b)
{
x = a;
y = b;
}
int main ()
{
rect rect;
rect.val (3, 4);
cout << "rect area: " << rect.area();
return 0;
}
b) rect area: 12
c) rect area:24
d) none of the mentioned
Answer:b
6. What is the output of this program?
#include <iostream>
using namespace std;
class CDummy
{
public:
int isitme (CDummy& param);
};
int CDummy::isitme (CDummy& param)
{
if (¶m == this)
return true;
else
return false;
}
int main ()
{
CDummy a;
CDummy *b = &a;
if (b->isitme(a)) {
cout << "execute";
}
else
{
cout<<"not execute";
}
return 0;
}
b) not execute
c) none of the mentioned
d) both a & b
Answer:a
7. Which of the following is a valid class declaration?
a) class A { int x; };
b) class B { }
c) public class A { }
d) object A { int x; };
Answer:a
8. The fields in the class in c++ program are by default
a) protected
b) private
c) public
d) none of the mentioned
Answer:b
9. Constructors are used to
a) initalize the objects
b) construct the data members
c) both a & b
d) none of the mentioned
Answer:a
10. When struct is used instead of the keyword class means, what will happen in the program?
a) access is public by default
b) access is private by default
c) access is protected by default
d) none of the mentioned
Answer:a