Summer Certification Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code = getmirror

Pass the C++ Institute C++ Certified Professional Programmer CPA-21-02 Questions and answers with ExamsMirror

Practice at least 50% of the questions to maximize your chances of passing.
Exam CPA-21-02 Premium Access

View all detail and faqs for the CPA-21-02 exam


788 Students Passed

91% Average Score

96% Same Questions
Viewing page 2 out of 8 pages
Viewing questions 11-20 out of questions
Questions # 11:

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

#include

#include

using namespace std;

class A {

public:

int age;

A () { age=5; };

};

class B : private A {

string name;

public:

B () { name="Bob"; };

void Print() {

cout << name << age;

}

};

int main () {

B b,*ob;

ob = &b;

ob?>age = 10;

ob?>Print();

return 0;

}

Options:

A.

It prints: Bob55

B.

It prints: Bob1

C.

It prints: 10

D.

Compilation error

Questions # 12:

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

#include

using namespace std;

class First

{

public:

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

};

class Second

{

public:

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

};

int main()

{

Second t[2];

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

t[i].Print();

}

Options:

A.

It prints: from First

B.

It prints: from Firstfrom First

C.

It prints: from Secondfrom Second

D.

It prints: from Second

Questions # 13:

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

#include

using namespace std;

int main()

{

long int x,y=10;

double d;

d = 3.99;

x=(int) d;

cout << x <<", ";

d=float (y);

cout << d;

return 0;

}

Options:

A.

It prints: 3, 10

B.

It prints: 3.99, 10

C.

It prints: 4, 10.0

D.

It prints: 4, 10

Questions # 14:

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

Question # 14

Options:

A.

It prints: 5.2110.0

B.

It prints: 5.210.0

C.

It prints: 52.10

D.

It prints: 5210

Questions # 15:

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

#include

using namespace std;

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

{

enum state { ok, error, warning};

enum state s1, s2, s3;

s1 = ok;

s2 = warning;

s3 = error;

s4 = ok;

cout << s1<< s2<< s3;

return 0;

}

Options:

A.

It will print:”123”

B.

compilation error

C.

It will print:”021”

D.

It will print:”132”

Questions # 16:

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

#include

using namespace std;

class BaseC

{

public:

int *ptr;

BaseC() { ptr = new int(10);}

BaseC(int i) { ptr = new int(i); }

~BaseC() { delete ptr; }

};

void fun(BaseC x);

int main()

{

BaseC *o = new BaseC(5);

fun(*o);

}

void fun(BaseC x) {

cout << "Hello:"<<*x.ptr;

}

Options:

A.

It prints: Hello:50

B.

It prints: Hello:10

C.

It prints: Hello:5

D.

Compilation error

Questions # 17:

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

#include

using namespace std;

int op(int x, int y);

int main()

{

int i=2, j=2, k;

float f=0.3;

k = op(i, j);

cout<< k << "," << op(1, f);

return 0;

}

int op(int x, int y)

{

return x+y;

}

Options:

A.

It prints: 4,1

B.

It prints: 4,0.7

C.

It prints: 4,0

D.

It prints: 0,4

Questions # 18:

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

Question # 18

Options:

A.

It prints: 13

B.

It prints: l

C.

It prints: 12

D.

It prints: 2

Questions # 19:

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

#include

#include

using namespace std;

class SampleClass

{

string *s;

public:

SampleClass() { s = new string("Text");}

SampleClass(string s) { this?>s = new string(s);}

~SampleClass() { delete s;}

void Print(){ cout<<*s;}

};

int main()

{

SampleClass *obj;

obj = new SampleClass("Test");

obj?>Print();

}

Options:

A.

It prints: Text

B.

It prints: Test

C.

It prints: TextTest

D.

Garbage value.

Questions # 20:

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

#include

#include

using namespace std;

class complex{

double re;

double im;

public:

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

bool operator==(complex &t);

};

bool complex::operator == (complex &t){

if((this?>re == t.re) && (this?>im == t.im))

return true;

else

return false;

}

int main(){

complex c1,c2;

if (c1==c2)

cout << "OK";

else {

cout << "ERROR";

}

}

Options:

A.

It prints: OK

B.

It prints: ERROR

C.

Compilation error

D.

Runtime error.

Viewing page 2 out of 8 pages
Viewing questions 11-20 out of questions
TOP CODES

TOP CODES

Top selling exam codes in the certification world, popular, in demand and updated to help you pass on the first try.