Free CPA – C++ Certified Associate Programmer Practice Test Question

Free demo downloads

Loading demo links...

Showing 13–15 of 15 questions

Question 13 (Volume B)

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

#include

using namespace std;

int main()

{

int i = 4;

while(i >= 0) {

cout<<>

i??;

}

return 0;

}

Select an option, then click Submit answer.

  • ○

    It prints:”43210”

  • ○

    It prints:”3210”

  • ○

    It prints: ”3210?1”

  • ○

    None of these

Question 14 (Volume A)

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

#include

using namespace std;

class A {

public:

int x;

A() { x=0;}

};

class B : public A {

public:

B() { x=1;}

};

class C : private B {

public:

C() { x=2;}

};

int main () {

C c1;

cout << c1.x;

return 0;

}

Select an option, then click Submit answer.

  • ○

    It prints: 210

  • ○

    It prints: 110

  • ○

    It prints: 010

  • ○

    Compilation error

Question 15 (Volume A)

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

#include

#include

using namespace std;

int mult(int f, int s, int t);

int main()

{

cout << mult(1,2,3);

return 0;

}

int mult(int f, int s, int t)

{

int mult_res;

mult_res = f*s*t;

return mult_res;

}

Select an option, then click Submit answer.

  • ○

    It prints: 0

  • ○

    It prints: 6

  • ○

    It prints: 2

  • ○

    It prints: 3