c++ institute CPA-21-02 Exam Questions

Questions for the CPA-21-02 were updated on : Nov 21 ,2025

Page 1 out of 18. Viewing questions 1-15 out of 257

Question 1

How many copies of the value member are stored in memory during program execution?

  • A. as many as objects of the A class plus one
  • B. as many as obiects of the A class and its inheritants
  • C. as many as objects of the A class
  • D. one
Answer:

D

User Votes:
A
50%
B
50%
C
50%
D
50%

Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 2

Which of the following statements are true? (Choose two.)

  • A. Class A's friend's friend is also a friend of class A
  • B. Friendship is inherited
  • C. A class may be a friend of many classes
  • D. A class may have many friends
Answer:

C, D

User Votes:
A
50%
B
50%
C
50%
D
50%

Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 3

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

  • A. using namespace myNamespace1; using namespace myNamespace2;
  • B. using namespace myNamespace1;
  • C. using namespace myNamespace1::y; using myNamespace2::x;
  • D. using namespace myNamespace2::y; using myNamespace1::x;
Answer:

C

User Votes:
A
50%
B
50%
C
50%
D
50%

Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 4

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

  • A. It prints: 3.14
  • B. It prints: Scring
  • C. It causes a compilation error
  • D. It prints: x
Answer:

D

User Votes:
A
50%
B
50%
C
50%
D
50%

Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 5

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

  • A. ob2.A::print();
  • B. ob2 –> A::print();
  • C. ob2.B::print();
  • D. ob2 –> B::print();
Answer:

A

User Votes:
A
50%
B
50%
C
50%
D
50%

Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 6

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

  • A. It prints: 1
  • B. lt prints: 2
  • C. It prints: 111
  • D. It prints: 121
Answer:

D

User Votes:
A
50%
B
50%
C
50%
D
50%

Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 7

Which line of code inserted instead of the comment will make the following code run properly
without causing memory leaks?

  • A. ~Base() ( delete this; }
  • B. no additional code is needed
  • C. ~Base() { delete ptr; delete ptr; }
  • D. ~Base() { delete ptr; }
Answer:

D

User Votes:
A
50%
B
50%
C
50%
D
50%

Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 8

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

  • A. It prints: 33
  • B. It prints: 007
  • C. It causes a compilation error
  • D. lit prints: 9
Answer:

C

User Votes:
A
50%
B
50%
C
50%
D
50%

Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 9

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

  • A. It prints: AAABDD
  • B. It pints: AABD
  • C. It prints: AABDD
  • D. It causes a compilation error
Answer:

D

User Votes:
A
50%
B
50%
C
50%
D
50%

Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 10

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

  • A. It prints: MaxNiels
  • B. It prints: RobertMax
  • C. It prints: RobertNiels
  • D. It causes a compilation error
Answer:

D

User Votes:
A
50%
B
50%
C
50%
D
50%

Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 11

What is the meaning of the following declaration? (Choose two.)
char **ptr;

  • A. ptr is a pointer to a pointer to char
  • B. ptr is a pointer to char*
  • C. ptr is a pointer to a pointer to a pointer to char
  • D. ptr is a pointer to char
Answer:

A, B

User Votes:
A
50%
B
50%
C
50%
D
50%

Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 12

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

  • A. It prints: 13
  • B. It prints: l
  • C. It prints: 12
  • D. It prints: 2
Answer:

D

User Votes:
A
50%
B
50%
C
50%
D
50%

Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 13

What is the expected output of the following program?

  • A. It prints: 432
  • B. It prints: 321
  • C. It prints: 4321
  • D. It prints: 3210
Answer:

B

User Votes:
A
50%
B
50%
C
50%
D
50%

Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 14

Which code line inserted instead of the comment below will fix the program so that it produces the
expected output and does not cause any memory leak?

  • A. delete [] p;
  • B. delete p[];
  • C. delete p;
  • D. delete *p;
Answer:

A

User Votes:
A
50%
B
50%
C
50%
D
50%

Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 15

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

  • A. It prints: 3
  • B. It prints: 4
  • C. It prints: 0
  • D. It prints: 6
Answer:

D

User Votes:
A
50%
B
50%
C
50%
D
50%

Discussions
vote your answer:
A
B
C
D
0 / 1000
To page 2