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: 24 May, 2026
Question 1

What will the variable "age" be in class B? class A { int x; protected: int y; public: int age; A () { age=5; }; }; class B : public A { string name; public: B () { name="Bob"; }; void Print() { cout << name << age; } };

Options :
Answer: A

Question 2

What happens when you attempt to compile and run the following code? #include using namespace std; int op(int x, int y); int main() { float *pf; float f=0.9; pf=&f; cout << op(1, *pf); return 0; } int op(int x, int y) { return x*y; }

Options :
Answer: A

Question 3

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


Options :
Answer: B

Question 4

What is the output of the program given below? #include using namespace std; int main (int argc, const char * argv[]) { enum state { ok, error, warning}; enum state s1, s2, s3, s4;  s1 = ok; s2 = warning; s3 = error; s4 = ok; cout << s1<< s2<< s3<< s4; return 0; }

Options :
Answer: C

Question 5

What happens when you attempt to compile and run the following code? #include using namespace std; int main() { const int x=0; const int *ptr; ptr = &x; cout<<*ptr; 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.