Halloween Special - Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: sntaclus

What happens when you attempt to compile and run the following code?

#include

#include

using namespace std;

class A {

public:

A() { cout << "A0 ";}

A(string s) { cout << "A1";}

};

class B : public A {

public:

B() { cout << "B0 ";}

B(string s) { cout << "B1 ";}

};

class C : private B {

public:

C() { cout << "C0 ";}

C(string s) { cout << "C1 ";}

};

int main () {

B b1;

C c1;

return 0;

}

A.

It prints: A0 B0 A0 B1 A0 C0 A0 C1

B.

It prints: B0 B1 C0 C1

C.

It prints: A0 B0 A0 B0 C0

D.

It prints: B0 B1

What is the output of the program given below?

#include

using namespace std;

int main (int argc, const char * argv[])

{

int i=10;

{

int i=0;

cout<

}

cout<

return 0;

}

A.

1010

B.

100

C.

010

D.

None of these

What happens when you attempt to compile and run the following code?

#include

using namespace std;

int fun(int x);

int main() {

cout << fun(0);

return 0;

}

int fun(int x) {

if(x > 0)

return fun(x-1);

else

return 100;

}

A.

It prints: 0

B.

It prints: 10

C.

It prints: 100

D.

It prints: -1

What happens when you attempt to compile and run the following code?

#include

using namespace std;

struct {

int x;

char c;

union {

float f;

int i;

};

} s;

int main (int argc, const char * argv[])

{

s.x=10;

s.i=0;

cout << s.i << " " << s.x;

}

A.

It prints: 0 10

B.

It prints: 11

C.

Compilation error

D.

None of these

What happens when you attempt to compile and run the following code?

#include

#include

using namespace std;

class A {

protected:

int y;

public:

int x;

int z;

A() { x=2; y=2; z=3; }

A(int a, int b) : x(a), y(b) { z = x ? y;}

void Print() {

cout << z;

}

};

int main () {

A a(2,5);

a.Print();

return 0;

}

A.

It prints: ?3

B.

It prints: 2

C.

It prints: 6

D.

It prints: 5

What happens when you attempt to compile and run the following code?

#include

using namespace std;

int main()

{

int x=2, *y, z=3;

y = &z;

cout<

return 0;

}

A.

It prints: 36

B.

It prints: 14

C.

It prints: 16

D.

Compilation error

What happens when you attempt to compile and run the following code?

#include

#include

using namespace std;

class First

{

string *s;

public:

First() { s = new string("Text");}

~First() { delete s;}

void Print(){ cout<<*s;}

};

int main()

{

First FirstObject;

FirstObject.Print();

FirstObject.~First();

}

A.

It prints: Text

B.

Compilation error

C.

Runtime error.

D.

None of these

What happens when you attempt to compile and run the following code?

#include

using namespace std;

class A

{

public:

void Print(){ cout<<"A";}

};

class B:public A

{

public:

void Print(){ cout<< "B";}

};

int main()

{

A *obj;

A ob1;

obj = &ob1;

obj?>Print();

B ob2;

obj = &ob2;

obj?>Print();

}

A.

It prints: AB

B.

It prints: AA

C.

It prints: BA

D.

It prints: BB

What happens when you attempt to compile and run the following code?

#include

using namespace std;

void fun(int*);

int main()

{

int i=2;

fun(&i);

cout<

return 0;

}

void fun(int *i)

{

*i = *i**i;

}

A.

It prints: 1

B.

It prints: 4

C.

It prints: 10

D.

It prints: 0

Which code, inserted at line 15, generates the output "5 Bob"?

#include

#include

using namespace std;

class B;

class A {

int age;

public:

A () { age=5; };

friend void Print(A &ob, B &so);

};

class B {

string name;

public:

B () { name="Bob"; };

//insert code here

};

void Print(A &ob, B &so) {

cout<

}

int main () {

A a;

B b;

Print(a,b);

return 0;

}

A.

friend void Print(A ob, B so);

B.

friend void Print(A &ob, B &so);

C.

friend void Print(A *ob, B *so);

D.

None of these