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 3 out of 8 pages
Viewing questions 21-30 out of questions
Questions # 21:

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

Question # 21

Options:

A.

It prints: 33

B.

It prints: –31

C.

It prints: –1–1

D.

It prints: –13

Questions # 22:

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

#include

using namespace std;

int main()

{

int a=5;

cout << ((a < 5) ? 9.9 : 9);

}

Options:

A.

It prints: 9

B.

It prints: 9.9

C.

Compilation error

D.

None of these

Questions # 23:

What is the output of the program?

#include

#include

using namespace std;

union t

{

char c;

int i;

};

class First

{

union t u;

public:

First() {

u.c = 'A';

}

void Print(){

cout << u.c;

}

};

int main()

{

First *t = new First();

t?>Print();

}

Options:

A.

Garbage value

B.

It prints: A

C.

It prints: A 65

D.

Compilation error

Questions # 24:

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

#include

using namespace std;

class A {

public :

void print() {

cout << "A ";

}

};

class B {

public :

void print() {

cout << "B ";

}

};

int main() {

B sc[2];

B *bc = (B*)sc;

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

(bc++)->print();

return 0;

}

Options:

A.

It prints: A A

B.

It prints: B B

C.

It prints: A B

D.

It prints: B A

Questions # 25:

What is the output of the program if characters 'h', 'e', 'l', 'l' , 'o' and enter are supplied as input?

#include

#include

using namespace std;

void f();

int main()

{

f();

return 0;

}

void f()

{

char c;

c = cin.get();

cout << c;

if(c != '\n')

f();

}

Options:

A.

It prints: hello

B.

It prints: olleh

C.

It prints: h

D.

It prints: o

Questions # 26:

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

#include

using namespace std;

int main(){

int i = 1;

if (i++==1) {

cout << i;

} else {

cout << i-1;

}

return 0;

}

Options:

A.

It prints: 0

B.

It prints: 1

C.

It prints: -1

D.

It prints: 2

Questions # 27:

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

#include

using namespace std;

int main()

{

int i=5;

switch(i)

{

case 1:

cout<<"Hello";

break;

case 2:

cout<<"world";

break;

case 3:

break;

default:

cout<<"End";

}

return 0;

}

Options:

A.

It prints: Hello

B.

It prints: world

C.

It prints: End

D.

It prints: Helloworld

Questions # 28:

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

#include

using namespace std;

void set(struct person*);

struct person

{

char name[25];

int age;

};

int main()

{

struct person e = {"Steve", 30};

set(&e);

cout<< e.name << " " << e.age;

return 0;

}

void set(struct person *p)

{

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

}

Options:

A.

Error: in prototype declaration unknown struct person

B.

Error: in structure

C.

It prints: Steve 31

D.

None of these

Questions # 29:

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;

};

class B : private A {

string name;

public:

void set() {

x = 1;

}

void Print() {

cout << x;

}

};

int main () {

B b;

b.set();

b.Print();

return 0;

}

Options:

A.

It prints: 123

B.

It prints: 1

C.

It prints: ?123

D.

Compilation error

Questions # 30:

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

#include

using namespace std;

int compare(int, int);

int main()

{

int x = compare(10, 20);

cout << x;

return 0;

}

int compare(int i, int j)

{

return i

}

Options:

A.

It prints: 0

B.

It prints: 2

C.

It prints: 1

D.

It prints: 10

Viewing page 3 out of 8 pages
Viewing questions 21-30 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.