Spring Sale Special Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: buysanta

Exact2Pass Menu

CPA - C++ Certified Associate Programmer

Last Update 19 hours ago Total Questions : 257

The CPA - C++ Certified Associate Programmer content is now fully updated, with all current exam questions added 19 hours ago. Deciding to include CPA-21-02 practice exam questions in your study plan goes far beyond basic test preparation.

You'll find that our CPA-21-02 exam questions frequently feature detailed scenarios and practical problem-solving exercises that directly mirror industry challenges. Engaging with these CPA-21-02 sample sets allows you to effectively manage your time and pace yourself, giving you the ability to finish any CPA - C++ Certified Associate Programmer practice test comfortably within the allotted time.

Question # 61

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

#include < iostream >

#include < string >

using namespace std;

const int size = 3;

class A {

public:

string name;

A() { name = " Bob " ;}

A(string s) { name = s;}

A(A & a) { name = a.name;}

};

class B : public A {

public:

int *tab;

B() { tab = new int[size]; for (int i=0; i < size; i++) tab[i]=1;}

B(string s) : A(s) { tab = new int[size]; for (int i=0; i < size; i++) tab[i]=1;}

~B() { delete tab; }

void Print() {

for (int i=0; i < size; i++) cout < < tab[i];

cout < < name;

}

};

int main () {

B b1( " Alan " );

B b2;

b1.tab[0]=0;

b1.Print(); b2.Print();

return 0;

}

A.

It prints: Alan

B.

It prints: 111

C.

It prints: 011Alan111Bob

D.

It prints: 0

Question # 62

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

#include < iostream >

#include < string >

using namespace std;

class A {

int x;

protected:

int y;

public:

int z;

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

};

class B : public A {

string z;

public:

void set() { y = 4; z = " John " ; }

void Print() { cout < < y < < A::z; }

};

int main () {

B b;

b.set();

b.Print();

return 0;

}

A.

It prints: 4John

B.

It prints: 2John

C.

It prints: 23

D.

It prints: 43

Question # 63

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

#include < iostream >

#include < string >

using namespace std;

int main()

{

string s1[]= { " H " , " t " };

string s;

for (int i=0; i < 2; i++) {

s = s1[i];

s.insert(1, " o " );

cout < < s;

}

return( 0 );

}

A.

It prints: Hoto

B.

It prints: Ho

C.

It prints: to

D.

It prints: Ht

Question # 64

What is the output of the program?

#include < iostream >

#include < string >

using namespace std;

int main()

{

string s1[]= { " H " , " t " };

string s;

for (int i=0; i < 2; i++) {

s = s1[i];

if (i==0)

s.insert(1, " ow " );

else

s.push_back( ' o ' );

cout < < s;

}

return( 0 );

}

A.

It prints: Hoto

B.

It prints: Ht

C.

It prints: toHo

D.

It prints: Howto

Question # 65

Which code, inserted at line 12, generates the output " 5b " ?

#include < iostream >

using namespace std;

namespace myNamespace1

{

int var = 5;

}

namespace myNamespace2

{

char var = ' b ' ;

}

int main () {

//insert code here

return 0;

}

A.

cout < < myNamespace1::var < < var;

B.

cout < < var < < var;

C.

cout < < myNamespace1::var < < myNamespace2::var;

D.

None of these

Question # 66

How many times will " HELLO " be printed?

#include < iostream >

using namespace std;

int main()

{

for(int i=?1; i < =10; i++)

{

if(i < 5)

continue;

else

break;

cout < < " HELLO " ;

}

return 0;

}

A.

1

B.

2

C.

0

D.

20

Question # 67

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

#include < iostream >

using namespace std;

class First

{

public:

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

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

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

};

int main()

{

First FirstObject;

FirstObject.Print();

}

A.

It prints: Constructorfrom First

B.

It prints: Constructorfrom FirstDestructor

C.

It prints: Constructorfrom FirstDestructorDestructor

D.

Compilation error at line 16

Question # 68

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

A.

It prints: 1

B.

It causes a compilation error

C.

It prints: -1

D.

It prints: 0

Question # 69

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

#include < iostream >

using namespace std;

int mul (int a, int b=2)

{

int r;

r=a*b;

return (r);

}

int main ()

{

cout < < mul(1) < < mul(2,4);

return 0;

}

A.

It prints: 2

B.

It prints: 28

C.

It prints: 8

D.

It prints: 6

Question # 70

Which of the following operations is INCORRECT?

A.

int i=15;

B.

long int k=123

C.

float f=12,2;

D.

double d=12;

Go to page: