C++ Institute CPA - C++ Certified Associate Programmer Exam Practice Test

Page:    1 / 14   
Total 220 questions

Question 1

Which definitions are correct?



Answer : A, C

Question 2

Which code, inserted at line 8, generates the output "100"?

#include

using namespace std;

int fun(int);

int main()

{

int *x = new int;

*x=10;

//insert code here

return 0;

}

int fun(int i)

{

return i*i;

}



Answer : A, B

Question 3

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

#include

using namespace std;

int fun(int x) {

return 2*x;

}

int main(){

int i;

i = fun(1) || fun(2);

cout << i;

return 0;

}



Answer : B

Question 4

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

#include

using namespace std;

int main()

{

int i = 5;

cout<<"Hello World" << ++i;

return 0;

}



Answer : A

Question 5

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

#include

using namespace std;

class First

{

public:

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

~First() { cout << "Destructor";}

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

};

int main()

{

First FirstObject;

FirstObject.Print();

}



Answer : B

Page:    1 / 14   
Total 220 questions