Classes

1

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

2

Constructors are used to

A. initalize the objects
B. construct the data members
C. both a & b
D. none of the mentioned

3

The fields in the class in c++ program are by default

A. protected
B. private
C. public
D. none of the mentioned

4

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; };

5

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.
    }
A. execute
B. not execute
C. none of the mentioned
D. both a & b