Weekend Special 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: save70

C++ Institute C++ Certified Professional Programmer CPA New Questions

Page: 7 / 8
Total 220 questions

C++ Certified Associate Programmer Questions and Answers

Question 25

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

#include

using namespace std;

int op(int x, int y)

{

int i;

i = x + y;

return i;

}

int main()

{

int i=1, j=2, k, l;

k = op(i, j);

l = op(j, i);

cout<< k << "," << l;

return 0;

}

Options:

A.

It prints: 1,2

B.

It prints: ?1,1

C.

It prints: 1,1

D.

It prints: 3,3

Question 26

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

#include

using namespace std;

class First

{

public:

virtual void Print(){ cout<<"from First";}

};

class Second:public First

{

public:

void Print(){ cout<< "from Second";}

};

void fun(First *obj);

int main()

{

First FirstObject;

fun(&FirstObject);

Second SecondObject;

fun(&SecondObject);

}

void fun(First *obj)

{

obj?>Print();

}

Options:

A.

It prints: from First

B.

It prints: from Firstfrom First

C.

It prints: from Firstfrom Second

D.

It prints: from Secondfrom Second

Question 27

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

#include

using namespace std;

int min(int a, int b);

int main()

{

int b=10;

b = min(5,20);

cout << b;

return 0;

}

int min(int a, int b)

{

if (a

return(a);

else

return(b);

}

Options:

A.

It prints: 10

B.

It prints: 20

C.

It prints: 5

D.

It prints: 0

Question 28

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

#include

using namespace std;

class First

{

public:

First() { cout << "Constructor";}

void Print(){ cout<<"from First";}

};

int main()

{

First FirstObject;

FirstObject.Print();

}

Options:

A.

It prints: Constructorfrom First

B.

It prints: Constructor

C.

It prints: from First

D.

None of these

Page: 7 / 8
Total 220 questions