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 5 out of 8 pages
Viewing questions 41-50 out of questions
Questions # 41:

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

#include

using namespace std;

int getValue();

int main()

{

const int x = getValue();

cout<

return 0;

}

int getValue()

{

return 5;

}

Options:

A.

It will print 0

B.

The code will not compile.

C.

It will print 5

D.

It will print garbage value

Questions # 42:

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

#include

using namespace std;

namespace myNamespace1

{

int x = 5;

int y = 10;

}

namespace myNamespace2

{

float x = 3.14;

float y = 1.5;

}

int main () {

{

using namespace myNamespace1;

cout << x << " ";

}{

using namespace myNamespace2;

cout << y;

}

return 0;

}

Options:

A.

It prints: 5 1.5

B.

It prints: 3.14 10

C.

Compilation error

D.

None of these

Questions # 43:

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.4) {}

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,c2,c3;

c3 = c1 ? c2;

c3.Print();

}

Options:

A.

It prints: 1 0.4

B.

It prints: 2 0.8

C.

It prints: 0 0

D.

It prints: 1 0.8

Questions # 44:

What is the output of the program?

#include

#include

using namespace std;

int main()

{

string s1="Wo";

string s2;

s2 = s1;

string s3;

s3 = s2.append("rldHello");

cout << s3;

return( 0 );

}

Options:

A.

It prints: WorldHello

B.

It prints: HelloWo

C.

It prints: World

D.

It prints: Hello

Questions # 45:

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

#include

#include

#include

using namespace std;

int main(void)

{

string s;

s = "Test";

s.resize (s.size() ? 1);

cout<

return 0;

}

Options:

A.

It prints: Test 4

B.

It prints: Test 3

C.

Compilation error

D.

It prints: Tes 3

Questions # 46:

What is the output of the program if characters 't', 'e', 's' and 't' enter are supplied as input?

#include

#include

using namespace std;

int main()

{

string s;

getline( cin, s );

cout << s << " " << s.length();

return( 0 );

}

Options:

A.

It prints: test 4

B.

It prints: test

C.

It prints: test 5

D.

It prints: 4

Questions # 47:

What is the output of the program?

#include

#include

using namespace std;

int main()

{

string s1="Hello";

string s2="World";

s1+=s2;

cout << s1;

return( 0 );

}

Options:

A.

It prints: HelloWorld

B.

It prints: Hello

C.

It prints: World

D.

It prints: HelWorld

Questions # 48:

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.4) {}

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,c2,c3;

c3 = c1 + c2;

c3.Print();

}

Options:

A.

It prints: 1 0.4

B.

It prints: 2 0.8

C.

It prints: 0 0

D.

Garbage value

Questions # 49:

What happens if character 3 is entered as input?

#include

using namespace std;

class A {

public:

int i;

};

int main () {

int c;

A obj;

obj.i = 5;

cin >> c;

try

{

switch (c)

{

case A. throw 20;

case B. throw 5.2f;

case C. throw obj;

default: cout<<"No exception";

}

}

catch (int e)

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

catch (A e)

{ cout << "object exception. Exception Nr. " << e.i; }

catch (...)

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

return 0;

}

Options:

A.

It prints: object exception. Exception Nr. 5

B.

It prints: int exception. Exception Nr.

C.

It prints: An exception occurred

D.

It prints: No exception

Questions # 50:

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

#include

#include

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;

}

Options:

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

Viewing page 5 out of 8 pages
Viewing questions 41-50 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.