Exam2pass
0 items Sign In or Register
  • Home
  • IT Exams
  • Guarantee
  • FAQs
  • Reviews
  • Contact Us
  • Demo
Exam2pass > C++ Institute > C++ Institute Certifications > CPA-21-02 > CPA-21-02 Online Practice Questions and Answers

CPA-21-02 Online Practice Questions and Answers

Questions 4

What is the output of the program?

#include

#include

using namespace std;

int main () {

string s1 = "Hello", s2 = "World";

s2 = s1 + s2;

cout << s2;

return 0;

}

A. It prints: Hello

B. It prints: HelloWorld

C. It prints: WorldHello

D. It prints: WorldHelloWorld

Buy Now

Correct Answer: B

Questions 5

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

#include

using namespace std;

void fun(int);

int main()

{

int a=0;

fun(a);

return 0;

}

void fun(int n)

{

if(n < 2)

{

fun(++n);

cout << n;

}

}

A. It prints: 21

B. It prints: 012

C. It prints: 0

D. None of these

Buy Now

Correct Answer: A

Questions 6

Which of the following can be checked in a switch?case statement?

A. char

B. int

C. enum

D. double

Buy Now

Correct Answer: ABC

Questions 7

What is the output of the program given below?

#include

using namespace std;

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

{

int i=10;

{

int i=0;

cout<

}

cout<

return 0;

}

A. 1010

B. 100

C. 010

D. None of these

Buy Now

Correct Answer: C

Questions 8

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

#include

using namespace std;

#define FUN(arg) if(arg) cout<<"Test";

int main()

{

int i=1;

FUN(i<3);

return 0;

}

A. It prints: 0

B. It prints: T

C. It prints: T0

D. It prints: Test

Buy Now

Correct Answer: D

Questions 9

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;

}

A. It prints: 5 1.5

B. It prints: 3.14 10

C. Compilation error

D. None of these

Buy Now

Correct Answer: A

Questions 10

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 andt);

};

bool complex::operator == (complex andt){

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

return true;

else

return false;

}

int main(){

complex c1,c2;

if (c1==c2)

cout << "OK";

else {

cout << "ERROR";

}

}

A. It prints: OK

B. It prints: ERROR

C. Compilation error

D. Runtime error.

Buy Now

Correct Answer: A

Questions 11

What will be the output of the program?

#include

using namespace std;

int main()

{

int i=0;

for(; i<=5; i++)

cout << i;

return 0;

}

A. 012345

B. 0123

C. 5

D. 6

Buy Now

Correct Answer: A

Questions 12

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

A. It causes a compilation error

B. It prints: Tesc failed

C. .It prints: failed

D. It prints: Tesc

Buy Now

Correct Answer: D

Questions 13

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

A. It prints: Hello:50

B. It prints: Hello:10

C. It prints: Hello:5

D. Compilation error

Buy Now

Correct Answer: C

Exam Code: CPA-21-02
Exam Name: CPA - C++ Certified Associate Programmer
Last Update: Jul 04, 2026
Questions: 257

PDF (Q&A)

$45.99
ADD TO CART

VCE

$49.99
ADD TO CART

PDF + VCE

$59.99
ADD TO CART

Exam2Pass----The Most Reliable Exam Preparation Assistance

There are tens of thousands of certification exam dumps provided on the internet. And how to choose the most reliable one among them is the first problem one certification candidate should face. Exam2Pass provide a shot cut to pass the exam and get the certification. If you need help on any questions or any Exam2Pass exam PDF and VCE simulators, customer support team is ready to help at any time when required.

Home | Guarantee & Policy |  Privacy & Policy |  Terms & Conditions |  How to buy |  FAQs |  About Us |  Contact Us |  Demo |  Reviews

2026 Copyright @ exam2pass.com All trademarks are the property of their respective vendors. We are not associated with any of them.