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

What is the output of the program if character 4 is supplied as input?

#include < iostream >

using namespace std;

int main () {

int c;

cin > > c;

try

{

switch (c)

{

case 1:

throw 20;

case 2:

throw 5.2f;

case 3:

throw ' a ' ;

default:

cout < < " No exception " ;

}

}

catch (int e)

{ cout < < " int exception. Exception Nr. " < < e; }

catch (float e)

{ cout < < " float exception. Exception Nr. " < < e; }

catch (...)

{ cout < < " An exception occurred. " ; }

return 0;

}

A.

It prints: float exception. Exception Nr.

B.

It prints: int exception. Exception Nr.

C.

It prints: An exception occurred

D.

It prints: No exception

Question # 32

Which of the structures is incorrect?

1:

struct s1{

int x;

long int li;

};

2:

struct s2{

float f;

struct s2 *s;

};

3:

struct s3{

float f;

struct s3 s;

};

A.

1

B.

2

C.

3

D.

2, 3

Question # 33

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

#include < iostream >

#include < string >

using namespace std;

class A {

public:

A() { cout < < " A no parameters " ;}

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

A(A & a) { cout < < " A object A parameter " ;}

};

class B : public A {

public:

B() { cout < < " B no parameters " ;}

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

};

int main () {

A a2( " Test " );

B b1( " Alan " );

B b2(b1);

return 0;

}

A.

It prints: A no parametersA no parametersB string parameter

B.

It prints: A string parameterA no parametersB string parameterA object A parameter

C.

It prints: A no parametersB string parameter

D.

It prints: A no parametersA no parameters

Question # 34

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

#include < iostream >

using namespace std;

class A {

public:

virtual void Print()=0;

};

class B:public A {

public:

virtual void Print() { cout < < " B " ; }

};

class C:public A {

public:

virtual void Print() { cout < < " C " ; }

};

int main()

{

B ob2;

C ob3;

A *obj;

obj = & ob2;

obj? > Print();

obj = & ob3;

obj? > Print();

}

A.

It prints: BC

B.

It prints: CB

C.

It prints: CC

D.

It prints: BB

Question # 35

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

A(int x) { this? > x=x;}

};

class B : private A {

public:

using A::x;

B() { x=1;}

B(int x) {this? > x = x;}

};

int main () {

B c1;

B c2(?5);

cout < < c1.x;

cout < < c2.x;

return 0;

}

A.

It prints: 5

B.

It prints: 1?5

C.

It prints: 05

D.

It prints: 0

Question # 36

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

#include < iostream >

using namespace std;

int main(){

int i = 1;

for(i=10; i > -1; i/=2) {

if(!i)

break;

}

cout < < i;

return 0;

}

A.

It prints: 0

B.

It prints: 1

C.

It prints: -1

D.

Compilation error

Question # 37

What will the variable " y " be in class B?

class A {

int x;

protected:

int y;

public:

int age;

};

class B : protected A {

string name;

public:

void Print() {

cout < < name < < age;

}

};

A.

public

B.

private

C.

protected

D.

None of these

Question # 38

What will be the output of the program?

#include < iostream >

using namespace std;

int main()

{

const int y = 5;

const x = ?10;

cout < < x < < " " < < y;

return 0;

}

A.

?10 5

B.

5 ?10

C.

Compilation error

D.

None of these

Question # 39

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

A.

It prints: 33

B.

It prints: 007

C.

It causes a compilation error

D.

lit prints: 9

Question # 40

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

#include < iostream >

#include < string >

using namespace std;

class Base

{

string s;

public:

Base() { s= " Sample text " ;}

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

void Print() { cout < < s; }

};

int main()

{

Base *o = new Base();

o? > Print();

}

A.

It prints: Sample text

B.

It prints: Sample

C.

It prints: text

D.

None of these

Go to page: