Leads4pass > 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 happens when you attempt to compile and run the following code?

#include

using namespace std;

class BaseClass

{

public:

int *ptr;

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

~BaseClass() { delete ptr; delete ptr;}

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

};

void fun(BaseClass x);

int main()

{

BaseClass o(10);

fun(o);

o.Print();

}

void fun(BaseClass x) {

cout << "Hello:";

}

A. It prints: Hello:1

B. It prints: Hello:

C. It prints: 10

D. Runtime error.

Buy Now
Questions 5

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
Questions 6

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

#include

using namespace std;

int main(){

int i, j;

for(i = 0, j = 1; j < 2, i < 4; i++, j++);

cout << i << " " << j;

return 0;

}

A. It prints: 4 5

B. It prints: 2 3

C. It prints: 3 2

D. It prints: 4 3

Buy Now
Questions 7

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()

{

First FirstObject;

FirstObject.Print();

Second SecondObject;

SecondObject.Print();

}

A. It prints: from First

B. It prints: from Firstfrom First

C. It prints: from Firstfrom Second

D. It prints: from Secondfrom Second

Buy Now
Questions 8

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

#include

using namespace std;

int fun(int x);

int main() {

cout << fun(0);

}

int fun(int x) {

if(x > 0)

return fun(x-1);

else

return 100;

}

A. It prints: 0

B. It prints: 10

C. It prints: 100

D. It prints: -1

Buy Now
Questions 9

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;

}

A. It will print:"123"

B. compilation error

C. It will print:"021"

D. It will print:"132"

Buy Now
Questions 10

Which code line instead of the comment below will cause the program to produce the expected output?

A. a = b * c;

B. return a = b * c;

C. return a = b * *c;

D. a = b * *c;

Buy Now
Questions 11

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

A. It prints: T

B. It prints an empty line

C. It prints: Tesc

D. It prints: st

Buy Now
Questions 12

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

}

A. It prints: 2 2

B. It prints: 1 1

C. It prints: 1 0

D. It prints: 0 0

Buy Now
Questions 13

Which of the following structures are correct?

1: struct s1{ int x; char c; };

2: struct s2{ float f; struct s2 *s; };

3: struct s3{

float f;

in i;

}

A. 1

B. 2

C. 3

D. All of these

Buy Now
Exam Code: CPA-21-02
Exam Name: CPA - C++ Certified Associate Programmer
Last Update: Jul 05, 2026
Questions: 257
10%OFF Coupon Code: SAVE10

PDF (Q&A)

$49.99

VCE

$55.99

PDF + VCE

$65.99