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 17 hours ago Total Questions : 257

The CPA - C++ Certified Associate Programmer content is now fully updated, with all current exam questions added 17 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 # 11

Which of the following is a logical operator?

A.

&

B.

& &

C.

||

D.

!

Question # 12

What will be the output of the program?

#include < iostream >

#include < string >

using namespace std;

int fun(int);

int main()

{

float k=3;

k = fun(k);

cout < < k;

return 0;

}

int fun(int i)

{

i++;

return i;

}

A.

3

B.

5

C.

4

D.

5

Question # 13

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

#include < iostream >

#include < string >

using namespace std;

class A {

public:

int x;

A() { x=0;}

};

class B {

public:

int x;

B() { x=1;}

};

class C :public A, public B {

public:

int x;

C(int x) {

this? > x = x;

A.

:x = x + 1;

}

void Print() { cout < < x < < A::x < < B::x; }

};

int main () {

C c2(1);

c2.Print();

return 0;

}

B.

It prints: 1

C.

It prints: 121

D.

It prints: 111

E.

It prints: 2

Question # 14

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;

};

class B : public A {

string name;

public:

void set() {

y = 2;

z = 3;

}

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

};

int main () {

B b;

b.set();

b.Print();

return 0;

}

A.

It prints: 123

B.

It prints: 000

C.

It prints: 23

D.

It prints: 12

Question # 15

What will be the output of the program?

#include < iostream >

using namespace std;

int fun(int);

int main()

{

cout < < fun(5);

return 0;

}

int fun(int i)

{

return i*i;

}

A.

25

B.

5

C.

0

D.

1

Question # 16

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

#include < cstdlib >

#include < iostream >

using namespace std;

inline float sum(float a,float b)

{

return a+b;

}

int main()

{

float a,b;

a = 1.5; b = 3.4;

cout < < sum(a,b);

return 0;

}

A.

It prints: 0

B.

It prints: 4.9

C.

It prints: 5

D.

It prints: 4

Question # 17

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

#include < iostream >

using namespace std;

namespace myNamespace1

{

int x = 5;

int y = 10;

}

namespace myNamespace2

{

float x = 3.14;

float y = 1.5;

}

int main () {

{

using namespace myNamespace1;

cout < < x < < " " ;

}{

using namespace myNamespace2;

cout < < y;

}

return 0;

}

A.

It prints: 5 1.5

B.

It prints: 3.14 10

C.

Compilation error

D.

None of these

Question # 18

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 x,y;

union t

{

char tab[2];

int i;

};

union t u;

u.tab[0] = 1;

u.tab[1] = 2;

u.i = 0;

x = u.tab[0];

y = u.tab[1];

cout < < x < < " , " < < y < < " , " < < u.i;

return 0;

}

A.

compilation fails

B.

It prints: 0,0,0

C.

It prints: 1,2,0

D.

None of these

Question # 19

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

#include < iostream >

using namespace std;

int fun(int x) {

return x < < 2;

}

int main(){

int i;

i = fun(1) / 2;

cout < < i;

return 0;

}

A.

It prints: 0

B.

It prints: 1

C.

It prints: 2

D.

It prints: 4

Question # 20

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

#include < iostream >

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

Go to page: