2026 Actual C++ Institute CPA-21-02 Dumps, Updated Exam Questions for Guaranteed Pass

CPA - C++ Certified Associate Programmer Exam - Free Practice Questions with Explanations, Exam Dumps, and Complete Practice Pack from DumpsProvider.

Exam Information

VendorC++ Institute
Exam codeCPA-21-02
Exam nameCPA - C++ Certified Associate Programmer Exam
Questions in pack257
Last updatedNovember 22, 2026
Related certificationsC++ Certified Associate Programmer

Free practice questions with explanations

C++ Institute CPA-21-02 Practice Questions

Answer a question to see the correct answer and the explanation, or click Show answer. Newest questions first.

Questions
17
Answered
0
Correct
0
Score
-
  1. 1 Question 1 Single choice Absolute Basics

    A junior developer at a logistics company compiles the following program with g++ -std=c++17 and is surprised by the output. The team must explain the behaviour in a code review before the release freeze. The program reads a single integer from standard input, then prints the result of dividing 17 by that value using integer arithmetic. The developer entered 4 and expected 4.25 to be printed. Which explanation is correct? int main() { int divisor; std::cin >> divisor; std::cout

  2. 2 Question 2 Multiple choice Accessing Data and Dealing with Exceptions

    A payments team maintains a C++ service that parses transaction amounts from text. Legacy code calls std::stoi on user-supplied strings and crashes with an uncaught exception in production. The team must keep the parsing function noexcept-free and must report malformed input to callers without terminating the process. Which TWO changes meet these requirements? (Choose two.)

  3. 3 Question 3 Order list Class Hierarchy

    A game studio is refactoring a rendering engine so that Sprite and Particle both derive from a common Drawable base class, and the base class must destroy derived objects correctly when deleted through a base pointer. A junior engineer must make the changes in the correct sequence so that the code compiles and behaves safely at runtime. Arrange the steps in the correct order.

    Drag the steps into the correct order, or use the arrows.

    1. Store Sprite and Particle objects in a std::vector of Drawable pointers.
    2. Delete each object through its Drawable pointer and verify that derived destructors run.
    3. Derive Sprite and Particle from Drawable using public inheritance.
    4. Declare a public virtual destructor in the Drawable base class.
  4. 4 Question 4 Drag and drop Flow Control and More Data Types

    A firmware team writes a loop that reads 32-bit sensor flags. The code must extract the sixth bit, clear the lowest bit, and compare two values for equality only when both are true. Match each requirement to the operator that meets it. Match each requirement to the operator that meets it.

    Drag each item onto its matching target. On a phone: tap an item, then tap a target.

    Combine two conditions so the branch runs only if both hold
    Clear the lowest bit of a flag word
    Test whether the sixth bit of a flag word is set
    Bitwise XOR
    Logical AND
    Logical NOT
    Bitwise AND with 0x20
    Bitwise AND with the complement of 1
  5. 5 Question 5 Dropdown Flow Control and More Data Types

    A scientific computing team stores measurement counts in an unsigned 16-bit field and needs to run a loop that processes exactly the values from 10 down to 1 inclusive, stopping as soon as the counter reaches zero, without relying on unsigned wraparound. Complete the loop by selecting the correct value for each blank. for ([1] count = 10; count [2] 0; [3]) { process(count); }

    Choose the correct value for each blank.

    for ( count = 10; count 0; ) {
    process(count);
    }
  6. 6 Question 6 Single choice Functions

    A finance application has a function that adds a surcharge to an order total. The team wants callers in legacy modules to keep calling apply_surcharge(total) with one argument, while new modules specify a custom rate with apply_surcharge(total, rate). The header must avoid ambiguity and the default must be a 2 percent rate. Which declaration best meets these requirements?

  7. 7 Question 7 Multiple choice Functions

    A robotics team's control library contains a function that writes status to a log buffer. Recent bugs were caused by callers passing a loop counter that the function silently modified through a reference parameter, changing the caller's variable. The team wants the function to accept large sensor structures cheaply and must prevent the modification and the copy. Which TWO parameter declarations meet these requirements? (Choose two.)

  8. 8 Question 8 Single choice Fundamentals of the Object-Oriented Approach

    A telemetry service keeps a count of active connections that must be shared across all instances of a Connection class, and the count must be initialized exactly once before any object is created. A developer places the definition of the counter inside the class body with the initializer. The build fails with an error about an in-class initializer for a non-const static member. The team has a strict rule against global variables in headers. Which fix meets the requirement?

  9. 9 Question 9 Dropdown Fundamentals of the Object-Oriented Approach

    A logistics system defines a Pallet class holding a weight in kilograms. Callers must be able to add two pallets with the plus operator, and the result must be a new object while both operands remain unchanged. The engineer must declare the operator as a member function and choose the correct parameter and qualifier. Complete the declaration by selecting the correct value for each blank. Pallet operator+([1] other) [2];

    Choose the correct value for each blank.

    Pallet operator+( other) ;
  10. 10 Question 10 Single choice More on Classes

    A plugin framework defines an abstract Codec base class with a virtual encode method. A third-party module derives from Codec and mistakenly declares its method as encode(const std::string&) instead of matching the base signature exactly. The compiler accepts the class without error, but calls through Codec pointers always invoke the base implementation. The team must detect this mismatch at compile time without changing the calling code. Which change is the BEST fix?

  11. 11 Question 11 Single choice More on Classes

    A graphics library defines an abstract Shape class with a pure virtual area method. A developer tries to create a Shape object directly in a test and the compiler rejects the code. The developer then asks why a class with a virtual function cannot be instantiated when concrete subclasses like Circle work fine. The team wants a concise explanation to share in the design document. Which statement is correct?

  12. 12 Question 12 Single choice The Basics of Functions

    A banking backend defines its own exception type, AccountError, derived from std::runtime_error. A function withdraw throws AccountError when funds are insufficient. A caller wraps the call in a try block with a catch clause for std::exception placed before a catch clause for AccountError. The team notices that the AccountError handler never runs in testing. What is the cause, and what is the correct fix?

  13. 13 Question 13 Drag and drop The Basics of Functions

    A payroll service has several exception types and must place each failure into the correct handling category so that the right recovery code runs. The team uses the standard exception hierarchy where std::logic_error and std::runtime_error are both derived from std::exception. Match each failure scenario to the standard exception class that best represents it.

    Drag each item onto its matching target. On a phone: tap an item, then tap a target.

    A caller passes a negative pay period count that violates a documented precondition
    A database response is truncated and the parsed result is unusable at runtime
    A computed index exceeds the valid range of a fixed-size container
    std::out_of_range
    std::bad_alloc
    std::runtime_error
    std::overflow_error
    std::invalid_argument
  14. 14 Question 14 Order list Accessing Data and Dealing with Exceptions

    A data-import tool must read a line from a file, convert it to an integer, and report a clear message if the file cannot be opened, without leaving the stream in an unhandled state. A developer writes the code step by step. Arrange the steps in the correct order.

    Drag the steps into the correct order, or use the arrows.

    1. Convert the string to an integer with std::stoi inside a try block.
    2. Catch std::invalid_argument and report the conversion failure to the user.
    3. Open the file with std::ifstream and check whether the stream is in a good state.
    4. Read a line into a std::string using std::getline.
  15. 15 Question 15 Single choice Class Hierarchy

    A healthcare application has a base class Device with a non-virtual destructor and a derived class Monitor that allocates an internal buffer. Code stores Monitor objects through Device pointers and deletes them. Valgrind reports that the buffer memory is never freed. The team must fix the leak with the smallest change that keeps the existing public interface. Which change is correct?

  16. 16 Question 16 Dropdown Class Hierarchy

    A vehicle fleet system defines a Vehicle base class and a Truck subclass. Truck must inherit publicly so that code holding Vehicle references can call its methods, and it must also expose a protected member that only derived classes can reach. The engineer must write the class header with the correct inheritance keyword and access specifier. Complete the declaration by selecting the correct value for each blank. class Truck [1] Vehicle { [2]: int payload_limit; };

    Choose the correct value for each blank.

    class Truck Vehicle {
    :
    int payload_limit;
    };
  17. 17 Question 17 Single choice Absolute Basics

    A build engineer at an embedded company is documenting how a C++ source file becomes an executable on the target toolchain. A teammate claims that the compiler performs the full job in one step and that the linker only runs when the program is first launched. The engineer must correct this in the build guide before the audit. Which statement gives the accurate sequence?

These are 17 of the 257 questions in the full CPA-21-02 pack.

Get All 257 Questions

Get all 257 questions & answers

733 Satisfied customers
93.7% Pass rate feedback
82.2% Said questions matched
95% Found material helpful

Full access options for C++ Institute CPA-21-02

Self-study

PDF Version

$40.00 $20.00
  • 257 actual exam questions
  • Compatible with all devices
  • Printable PDF format
  • No download limits
  • 90 days free updates
  • 24/7 customer support

Exam simulation

Online Practice Test

$50.00 $25.00
  • 257 actual exam questions
  • Actual exam environment
  • 90 days free updates
  • Browser-based software
  • 24/7 customer support

100% Money Back Guarantee

Your success comes first

At DumpsProvider, we give you a 100% money back guarantee on all of our exam dumps. For us, your success is the #1 priority and we are more than confident that our exam material will help you pass the CPA-21-02 Exam (CPA - C++ Certified Associate Programmer Exam) on your very first attempt.

In a rare case, if you fail your exam, we will refund your amount without asking a single question.

100%

Security & Privacy

10000+

Satisfied Customers

24/7

Committed Service

100%

Money Back Guranteed