Free CPA-21-02 Mock Exam – Practice Online Confidently

Increase your chances of passing the C++ Institute CPA-21-02 exam questions on your first try. Practice with our free online CPA-21-02 exam mock test designed to help you prepare effectively and confidently.

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

What happens when you attempt to compile and run the following code? #include #include using namespace std; class A { public: int x; A() { x=0;} A(int x) { this?>x=x;} }; class B : private A { public: using A::x; B() { x=1;} B(int x) {this?>x = x;} }; int main () { B c1; B c2(?5); cout << c1.x; cout << c2.x; return 0; }

Options :
Answer: B

Question 2

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


Options :
Answer: C

Question 3

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 4

How could you pass arguments to functions? 

Options :
Answer: A,B,C

Question 5

What happens when you attempt to compile and run the following code? #include #include using namespace std; class A { protected: int y; public: int x, z; A() : x(1), y(2), z(0) {} A(int a, int b) : x(a), y(b) { z = x * y;} void Print() { cout << z; } }; class B : public A { public: int y; B() : A() {} B(int a, int b) : A(a,b) {} void Print() { cout << z; } }; int main () { A b(2,5); b.Print(); return 0; }

Options :
Answer: A

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

© Copyrights FreeMockExams 2026. All Rights Reserved

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