1) What is the output of the sizeof operator for the variable ‘t’ in the following code snippet? (Assume sizeof(int) = 4).class Test {    int var;     int arr[9];    void display() { int a;}};int main() {    Test t;    cout << sizeof(t) << ” “;}

a) 40
b) 36
c) 44
d) Default size: 0

Answer(s) : 
a) 40

[quads id=1]

2) What will be the output / error of the  following program?#includeusing namespace std;class Sample {    int data_;    Sample(): data_(2){}};int main() {    Sample s;    s.data_ = 1;    cout << Sample.data_;}

a) 1
b) 2
c) Compilation Error: Sample() is private
d) 0

Answer(s) : 
c) Compilation Error: Sample() is private

3) What is the output of the following program ? #includeusing namespace std;class Test {  private:      int x_;    int y_;public:    void func() {         x_ = y_ = 1;         cout << x_ << ” ” << y_;    }};int main() {    Test t;    t.func();}

a) 1  1
b) Compilation error: Constructor not defined
c) Compilation error: Cannot access private member ‘x’ and ‘y’
d) Compilation error: Illegal access of func()

Answer(s) : 
a) 1 1

[quads id=1]

4) Consider Object S of class Sample. What is the type of this pointer ? 

a) S const * const this
b) S * const this
c) S * this
d) const S const * this

Answer(s) : 
b) S * const this

5) What is the o/p of the following code snippet ?class Sample {      string name;public:     Sample(string s): name(s) {     cout << name << ” Created” << ” “;}     ~Sample() {          cout << name << ” Destroyed” << ” “;      }};int main() {     Sample s1(“s1”), s2(“s2”);     return 0;}

a) S1 Created S2 Created S2 Destroyed S1 Destroyed
b) S1 Created S2 Created S1 Destroyed S2 Destroyed
c) S2 Created S1 Created S2 Destroyed S1 Destroyed
d) S1 Created S1 Destroyed S2 Created S2 Destroyed

Answer(s) : 
a) S1 Created S2 Created S2 Destroyed S1 Destroyed