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 4 out of 8 pages
Viewing questions 31-40 out of questions
Questions # 31:

What is the output of the program?

#include

#include

using namespace std;

struct t

{

int tab[2];

};

class First

{

struct t u;

public:

First() {

u.tab[0] = 1;

u.tab[1] = 0;

}

void Print(){

cout << u.tab[0] << " " << u.tab[1];

}

};

int main()

{

First t;

t.Print();

}

Options:

A.

It prints: 2 2

B.

It prints: 1 1

C.

It prints: 1 0

D.

It prints: 0 0

Questions # 32:

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

#include

using namespace std;

class A

{

public:

virtual void Print()=0;

};

class B:public A

{

public:

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

};

int main()

{

B ob2;

A *obj;

obj = &ob2;

obj?>Print();

}

Options:

A.

It prints: B

B.

It prints: A

C.

It prints: AB

D.

It prints: BA

Questions # 33:

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

#include

using namespace std;

int fun(int x) {

return 2*x;

}

int main(){

int i;

i = fun(0.5) || fun(0);

cout << i;

return 0;

}

Options:

A.

It prints: 0

B.

It prints: 1

C.

It prints: -1

D.

Compilation error

Questions # 34:

What is the expected result of the following program?

Question # 34

Options:

A.

It prints: 4

B.

The program enters an infinite loop

C.

It prints: 42

D.

It prints: 420

Questions # 35:

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 First

{

public:

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

};

void fun(First *obj);

int main()

{

First FirstObject;

fun(&FirstObject);

Second SecondObject;

fun(&SecondObject);

}

void fun(First *obj)

{

obj?>Print();

}

Options:

A.

It prints: from First

B.

It prints: from Firstfrom First

C.

It prints: from Firstfrom Second

D.

It prints: from Secondfrom Second

Questions # 36:

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

#include

#include

using namespace std;

struct Person {

string name;

int age;

};

class First

{

Person *person;

public:

First() {person = new Person;

person?>name = "John";

person?>age = 30;

}

void Print(){

cout<name << " "<< person?>age;

}

};

int main()

{

First t;

t.Print();

}

Options:

A.

It prints: 30

B.

It prints: John

C.

It prints: John 30

D.

It prints: John 30John 30

Questions # 37:

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

#include

#include

using namespace std;

class complex{

double re, im;

public:

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

complex(double n) { re=n,im=n;};

complex(int m,int n) { re=m,im=n;}

complex operator+(complex &t);

void Print() { cout << re << " " << im; }

};

complex complex::operator+ (complex &t){

complex temp;

temp.re = this?>re + t.re;

temp.im = this?>im + t.im;

return temp;

}

int main(){

complex c1(1),c2(2),c3;

c3 = c1 + c2;

c3.Print();

}

Options:

A.

It prints: 1 1.5

B.

It prints: 2 1.5

C.

It prints: 3 3

D.

It prints: 0 0

Questions # 38:

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

#include

#include

using namespace std;

class A {

int x;

protected:

int y;

public:

int z;

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

};

class B : public A {

public:

void set() {

y = 4; z = 2;

}

void Print() {

cout << y << z;

}

};

int main () {

B b;

b.set();

b.Print();

return 0;

}

Options:

A.

It prints: 42

B.

It prints: 44

C.

It prints: 22

D.

It prints: 2

Questions # 39:

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

Question # 39

Options:

A.

It prints: 1

B.

It causes a compilation error

C.

It prints: -1

D.

It prints: 0

Questions # 40:

Which of the following is a logical operator?

Options:

A.

&

B.

&&

C.

||

D.

!

Viewing page 4 out of 8 pages
Viewing questions 31-40 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.