Summer Special Limited Time 65% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: dcdisc65

Page: 1 / 8
Total 77 questions
Exam Code: CPA-21-02                Update: Oct 15, 2025
Exam Name: CPA - C++ Certified Associate Programmer

C++ Institute CPA - C++ Certified Associate Programmer CPA-21-02 Exam Dumps: Updated Questions & Answers (October 2025)

Question # 1

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

#include

using namespace std;

class complex{

double re;

double im;

public:

complex() : re(0),im(0) {}

complex(double x) { re=x,im=x;};

complex(double x,double y) { re=x,im=y;}

void print() { cout << re << " " << im;}

};

int main(){

complex c1;

double i=2;

c1 = i;

c1.print();

return 0;

}

A.

It prints: 0 0

B.

It prints: 1 1

C.

It prints: 2 0

D.

It prints: 2 2

Question # 2

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

#include

using namespace std;

void fun(char*);

int main()

{

char t[4]={'0', '1', '2', '3'};

fun(&t[2]);

return 0;

}

void fun(char *a)

{

cout << *a;

}

A.

It prints: 2

B.

It prints: 21

C.

It prints: 00

D.

It prints: 02

Question # 3

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

Question # 4

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

#include

using namespace std;

int main()

{

int x=0;

int *ptr;

ptr = &x;

cout<

return 0;

}

A.

It prints: 0 0

B.

It prints address of ptr

C.

It prints: 1

D.

It prints: 2

Question # 5

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

#include

using namespace std;

void fun(int);

int main()

{

int a=0;

fun(a);

return 0;

}

void fun(int n)

{

if(n < 2)

{

fun(++n);

cout << n;

}

}

A.

It prints: 21

B.

It prints: 012

C.

It prints: 0

D.

None of these

Question # 6

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;

}

A.

It prints: 210

B.

It prints: 110

C.

It prints: 010

D.

Compilation error

Question # 7

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

#include

#include

using namespace std;

class A {

public:

A() { cout << "A no parameters";}

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

A(A &a) { cout << "A object A parameter";}

};

class B : public A {

public:

B() { cout << "B no parameters";}

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

};

int main () {

A a2("Test");

B b1("Alan");

B b2(b1);

return 0;

}

A.

It prints: A no parametersA no parametersB string parameter

B.

It prints: A string parameterA no parametersB string parameterA object A parameter

C.

It prints: A no parametersB string parameter

D.

It prints: A no parametersA no parameters

Question # 8

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

#include

using namespace std;

int main()

{

const int x=20;

const int *ptr;

ptr = &x;

*ptr = 10;

cout<<*ptr;

return 0;

}

A.

It prints: 20

B.

It prints: 10

C.

Compilation error at line 8

D.

It prints address of ptr

Question # 9

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

#include

#include

#include

using namespace std;

int main(void)

{

string s;

s = "Test";

s.resize (s.size() ? 1);

cout<

return 0;

}

A.

It prints: Test 4

B.

It prints: Test 3

C.

Compilation error

D.

It prints: Tes 3

Question # 10

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

#include

using namespace std;

int main()

{

float x=3.5,y=1.6;

int i,j=2;

i = x + j + y;

cout << i;

return 0;

}

A.

It prints: 7

B.

It prints: 6

C.

It prints: 7,1

D.

Compilation error

Page: 1 / 8
Total 77 questions

Most Popular Certification Exams

Payment

       

Contact us

dumpscollection live chat

Site Secure

mcafee secure

TESTED 16 Oct 2025