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

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

#include < iostream >

using namespace std;

void set(struct person*);

struct person

{

int age;

};

int main()

{

struct person e = {18};

set( & e);

cout < < e.age;

return 0;

}

void set(struct person *p)

{

p? > age = p? > age + 1;

}

A.

It prints: 18

B.

It prints: 19

C.

It prints: 20

D.

It prints: 0

Question # 52

What is the output of the program?

#include < iostream >

#include < string >

using namespace std;

int main()

{

string s1= " Hello " ;

string s2= " World " ;

s1+=s2;

cout < < s1;

return( 0 );

}

A.

It prints: HelloWorld

B.

It prints: Hello

C.

It prints: World

D.

It prints: HelWorld

Question # 53

What is the output of the program?

#include < iostream >

#include < string >

using namespace std;

int main()

{

string s1[]= { " Hello " , " World " };

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

cout < < s1[i];

}

return( 0 );

}

A.

It prints: HelloWorld

B.

It prints: Hello

C.

It prints: WorldHello

D.

It prints: World

Question # 54

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

#include < iostream >

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

What is the output of the program given below?

#include < iostream >

using namespace std;

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

{

int i=10;

{

int i=0;

cout < < i;

}

{

int i=5;

cout < < i;

}

cout < < i;

return 0;

}

A.

1010

B.

101010

C.

0510

D.

None of these

Question # 56

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

#include < iostream >

#include < string >

using namespace std;

class A {

public:

string s;

A(string s) { this? > s = s; }

};

class B {

public:

string s;

B (A a) { this? > s = a.s; }

void print() { cout < < s; }

};

int main()

{

A a( " Hello world " );

B b=a;

b.print();

}

A.

It prints: Hello world

B.

It prints: Hello

C.

Compilation error

D.

None of these

Question # 57

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

#include < iostream >

#include < string >

using namespace std;

class A {

protected:

int y;

public:

int x;

int z;

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

A(int a, int b) : x(a), y(b) { z = x ? y;}

void Print() {

cout < < z;

}

};

int main () {

A a(2,5);

a.Print();

return 0;

}

A.

It prints: ?3

B.

It prints: 2

C.

It prints: 6

D.

It prints: 5

Question # 58

What is the output of the program?

#include < iostream >

using namespace std;

class Base {

static int age;

public:

Base () {};

~Base () {};

void setAge(int a=10) {age = a;}

void Print() { cout < < age;}

};

int Base::age=0;

int main () {

Base a,*b;

b = new Base();

a.setAge();

b? > setAge(20);

a.Print();

b? > Print();

return 0;

}

A.

It prints: 2020

B.

It prints: 1020

C.

It prints: 20

D.

It prints: 10

Question # 59

How many times will the program print " HELLO " ?

#include < iostream >

using namespace std;

int main()

{

cout < < " HELLO " ;

main();

return 0;

}

A.

65536

B.

32769

C.

1

D.

Till stack overflows

Question # 60

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

#include < iostream >

using namespace std;

int f(int a, int b);

int main()

{

float b;

b = f(20,10);

cout < < b;

return 0;

}

int f(int a, int b)

{

return a/b;

}

A.

It prints: 2

B.

It prints: 5

C.

It prints: 10

D.

It prints: 0

Go to page: