C++ Institute CPA-21-02 Practice Exam Questions & Answers
C++ Institute CPA-21-02 Exam Details
Key details for this exam, checked against the published exam outline
- Exam Code
- CPA-21-02
- Full Name
- CPA - C++ Certified Associate Programmer Exam
- Issuing Body
- C++ Institute
- Question Format (Our Bank)
- Multiple Choice
- Official Exam Fee
- USD 325. USD 375 (Exam + Retake)
- Delivery
- Pearson VUE Test Center or Pearson VUE OnVUE Online Proctoring
- Full Question Set
- 257 questions Get All Questions
Free CPA-21-02 Practice Questions
Each question shows the correct answer and an explanation of why it is right
Question 1 Domain 2 Flow Control and More Data Types
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);
return 0;
}
int fun(int x) {
if(x > 0)
return fun(x-1);
else
return 100;
}
Question 2 Domain 4 Accessing Data and Dealing with Exceptions
What happens when you attempt to compile and run the following code?
#include
using namespace std;
int main()
{
const char *s;
char str[] = "Hello";
s = str;
while(*s) {
cout << *s++;
}
return 0;
}
Question 3 Domain 6 Class Hierarchy
What happens when you attempt to compile and run the following code?
#include
using namespace std;
int main(){
int i = 1;
if (i++==1) {
cout << i;
} else {
cout << i-1;
}
return 0;
}
Get the complete CPA-21-02 question set
$20$40
Question 4 Domain 4 Accessing Data and Dealing with Exceptions
What happens when you attempt to compile and run the following code?
#include
using namespace std;
class complex{
double re;
double im;
public:
complex() : re(0),im(0) {}
complex(double x) { re=x,im=x;};
complex(double x,double y) { re=x,im=y;}
void print() { cout << re << " " << im;}
};
int main(){
complex c1(1,2);
c1.print();
return 0;
}
Question 5 Domain 1 Absolute Basics
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;
}
Question 6 Domain 3 Functions
What will happen when you attempt to compile and run the following code?
#include
#include
using namespace std;
string fun(string, string);
int main()
{
string s="Hello";
cout << fun(s, " World");
return 0;
}
string fun(string s1, string s2)
{
return s1+s2;
}
Question 7 Domain 5 Fundamentals of the Object-Oriented Approach
What happens when you attempt to compile and run the following code?
#include
using namespace std;
void fun(char*);
int main()
{
char t[4]={'0', '1', '2', '3'};
fun(&t[0]);
return 0;
}
void fun(char *a)
{
cout << *a;
}
What the C++ Institute CPA-21-02 Exam Covers
Exam domains verified against the Official C++ Institute CPA-21-02 exam guide, last checked November 2026.
Domain 1 Absolute Basics
Covers foundational programming concepts including machine and high-level languages, compilation, variables, integers, characters, streams and basic input/output. This is where you learn to write your first working programs and understand how code becomes machine executable.
Sample question from this domain above Q5
Domain 2 Flow Control and More Data Types
Explores program flow control, floating point and additional integer types, loops, and operators including logic, bitwise and arithmetic operations. Mastering these allows you to write programs that make decisions and repeat actions based on conditions.
Sample question from this domain above Q1
Domain 3 Functions
Focuses on function declaration, invocation, parameters, default parameters, inline functions and overloaded functions. Functions let you break large programs into manageable reusable pieces and are essential to writing maintainable code.
Sample question from this domain above Q6
Domain 4 Accessing Data and Dealing with Exceptions
Covers type conversion, strings as objects with methods and properties, namespaces, and exception handling. Understanding exceptions helps you write robust code that handles errors gracefully rather than crashing.
Domain 5 Fundamentals of the Object-Oriented Approach
Introduces classes, objects, constructors, static members, friend classes and operator overloading. Object-oriented programming organizes code around data and the operations that work on that data, making large projects easier to manage.
Sample question from this domain above Q7
Domain 6 Class Hierarchy
Explores inheritance, base classes, subclasses, types of inheritance and multiple inheritance. Inheritance lets you create new classes based on existing ones, avoiding code duplication and building organized hierarchies of related types.
Sample question from this domain above Q3
Domain 7 More on Classes
Delves into polymorphism, virtual methods, abstract classes and abstraction. These advanced class concepts allow objects of different types to behave differently while using the same interface, enabling flexible and extensible designs.
Domain 8 The Basics of Functions
Focuses on exceptions in programming, covering what exceptions are, how to catch and throw them, exception class hierarchies and defining custom exceptions. This topic teaches defensive programming practices that keep applications stable when unexpected situations occur.
CPA-21-02 Exam FAQ
Common questions about the exam itself
What prior experience do I need before taking the CPA-21-02 exam?
How hard is the CPA-21-02 exam and what makes it challenging?
How long should I spend studying for CPA-21-02?
Can I retake CPA-21-02 if I fail?
What happens on exam day when I take CPA-21-02?
How much does the CPA-21-02 exam cost?
What format are the CPA-21-02 questions?
How does CPA-21-02 relate to other C++ Institute exams?
How long is the CPA-21-02 certification valid for?
What job roles benefit from having the CPA-21-02 certification?
Other C++ Institute Exams
Free practice questions for more C++ Institute certification exams
