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 # 21

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

#include < iostream >

using namespace std;

int main(){

int i = 1;

if (i==1) {

cout < < i;

} else {

cout < < i-1;

}

return 0;

}

A.

It prints: 0

B.

It prints: 1

C.

It prints: -1

D.

It prints: 2

Question # 22

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

#include < iostream >

using namespace std;

int main(int argc, char *argv[]) {

char *s = " ABCDEF " ;

cout < < s+2;

return 0;

}

A.

It prints: CDEF

B.

It prints: ABCDEF

C.

It prints: BCDEF

D.

None of these

Question # 23

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

#include < iostream >

using namespace std;

int main()

{

int i=2;

switch(i)

{

case 1:

cout < < " Hello " ;

break;

case 2:

cout < < " world " ;

break;

case 3:

printf( " End " );

break;

}

return 0;

}

A.

It prints: Hello

B.

It prints: world

C.

It prints: End

D.

It prints: E

Question # 24

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

#include < iostream >

#include < string >

using namespace std;

int fun(int);

int main()

{

int *x = new int;

*x=10;

cout < < fun(*x);

return 0;

}

int fun(int i)

{

return i*i;

}

A.

It will print: 100

B.

It will print: 101

C.

It will print: 10

D.

It will print: 1

Question # 25

Which of the following operators accept integer arguments only? (Choose two.)

A.

|

B.

| |

C.

~

D.

!

Question # 26

Which of the following statements are correct about an array?

int tab[10];

A.

The array can store 10 elements.

B.

The expression tab[1] designates the very first element in the array.

C.

The expression tab[9] designates the last element in the array.

D.

It is necessary to initialize the array at the time of declaration.

Question # 27

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

#include < iostream >

using namespace std;

int main (int argc, const char * argv[])

{

int tab[5]={1,2,3};

for (int i=0; i < 5; i++)

cout < < tab[i];

return 0;

}

A.

compilation fails

B.

It prints: 12300

C.

It prints: 12345

D.

It prints: 00000

Question # 28

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

#include < iostream >

#include < string >

using namespace std;

class complex{

double re, im;

public:

complex() : re(1),im(0.3) {}

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

complex(int m,int n) { re=m,im=n;}

complex operator+(complex & t);

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

};

complex complex::operator+ (complex & t){

complex temp;

temp.re = this? > re + t.re;

temp.im = this? > im + t.im;

return temp;

}

int main(){

complex c1(1),c2(2),c3;

c3 = c1 + c2;

c3.Print();

}

A.

It prints: 1 1.5

B.

It prints: 2 1.5

C.

It prints: 3 3

D.

It prints: 0 0

Question # 29

What will be the output of the program?

#include < iostream >

using namespace std;

int main()

{

int i=0;

for(; i < =5; i++)

cout < < i;

return 0;

}

A.

012345

B.

0123

C.

5

D.

6

Question # 30

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];

s.insert(1, " ow " );

cout < < s;

}

return( 0 );

}

A.

It prints: How

B.

It prints: Ht

C.

It prints: Hoto

D.

It prints: Howtow

Go to page: