Higher Test Marks with Free Online CPA-21-02 Exam Practice

Assess the CertsIQ’s updated CPA-21-02 exam questions for free online practice of your CPA C++ Certified Associate Programmer test. Our CPA 21-02 dumps questions will enhance your chances of passing the C++ Certified Professional Programmer certification exam with higher marks.

Exam Code: CPA-21-02
Exam Questions: 257
CPA C++ Certified Associate Programmer
Updated: 18 Feb, 2026
Question 1

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

Options :
Answer: C

Question 2

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

Options :
Answer: C

Question 3

What happens when you attempt to compile and run the following code? #include using namespace std; int main() { int i, j; for(i = 0; i < 2; i++) { for(j = i; j < i + 1; j++) if(j == i) continue; else break; } cout << j; return 0; }

Options :
Answer: C

Question 4

What happens if characters 'w', 'o', 'r', 'l' and 'd' are entered as input? #include #include using namespace std; int main() { string s1 = "Hello"; string s2; getline( cin, s2 ); cout << s1 + s2; return( 0 ); } 

Options :
Answer: A

Question 5

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? 


Options :
Answer: A

Viewing Page : 1 - 26
Practicing : 1 - 5 of 257 Questions

© Copyrights CertsIQ 2026. All Rights Reserved

We use cookies to ensure that we give you the best experience on our website (CertsIQ). If you continue without changing your settings, we'll assume that you are happy to receive all cookies on the CertsIQ.