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

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

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

#include < iostream >

using namespace std;

int main()

{

union un

{

int x;

char c;

};

union un u1 = {10};

union un u2 = { ' a ' };

union un u3 = {20, ' a ' };

cout < < u1.x;

cout < < u2.c;

cout < < u3.c;

return 0;

}

A.

It prints: 10aa

B.

It prints: 10a20a

C.

It prints: 1a

D.

Compilation error

Question # 5

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

#include < iostream >

#include < string >

using namespace std;

class A {

public:

A() { cout < < " A0 " ;}

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

};

class B : public A {

public:

B() { cout < < " B0 " ;}

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

};

class C : private B {

public:

C() { cout < < " C0 " ;}

C(string s) { cout < < " C1 " ;}

};

int main () {

B b1;

C c1;

return 0;

}

A.

It prints: A0 B0 A0 B1 A0 C0 A0 C1

B.

It prints: B0 B1 C0 C1

C.

It prints: A0 B0 A0 B0 C0

D.

It prints: B0 B1

Question # 6

What is the output of the program?

#include < iostream >

using namespace std;

int main()

{

int tab[4]={10,20,30,40};

tab[1]=10;

int *p;

p= & tab[0];

cout < < *p;

return 0;

}

A.

It prints: 10

B.

It prints: 20

C.

It prints: 11

D.

It prints: 30

Question # 7

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

#include < iostream >

#include < exception >

using namespace std;

class myClass : public exception

{

virtual const char* what() const throw()

{

return " My exception. " ;

}

} obj;

int main () {

try

{

throw obj;

}

catch (exception & e)

{

cout < < e.what() < < endl;

}

return 0;

}

A.

It prints: My exception.

B.

It prints: 0

C.

It prints: 1

D.

Compilation error

Question # 8

What is the output of the program?

#include < iostream >

#include < string >

using namespace std;

class First

{

string name;

public:

First() {

name = " Alan " ;

}

void Print(){

cout < < name;

}

};

int main()

{

First ob1,*ob2;

ob2 = new First();

ob1.Print();

ob2? > Print();

}

A.

Garbage value

B.

It prints: AlanAlan

C.

It prints: Alan

D.

It prints: Al

Question # 9

What is the output of the program?

#include < iostream >

#include < string >

using namespace std;

int main () {

string s1 = " Hello " , s2 = " World " ;

s2 = s1 + s2;

cout < < s2;

return 0;

}

A.

It prints: Hello

B.

It prints: HelloWorld

C.

It prints: WorldHello

D.

It prints: WorldHelloWorld

Question # 10

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

#include < iostream >

using namespace std;

class First

{

public:

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

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

};

int main()

{

First FirstObject;

FirstObject.Print();

}

A.

It prints: Constructorfrom First

B.

It prints: Constructor

C.

It prints: from First

D.

None of these

Go to page: