CPA-21-02 Exam Details

  • Exam Code
    :CPA-21-02
  • Exam Name
    :CPA - C++ Certified Associate Programmer
  • Certification
    :C++ Institute Certifications
  • Vendor
    :C++ Institute
  • Total Questions
    :257 Q&As
  • Last Updated
    :May 30, 2026

C++ Institute CPA-21-02 Online Questions & Answers

  • Question 191:

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

    #include

    using namespace std;

    int main()

    {

    int i = 0;

    do {

    i++;

    if (i==3)

    break;

    cout<

    }

    while(i < 5);

    return 0;

    }

    A. It prints: 12
    B. It prints: 1
    C. It prints: 0
    D. No output

  • Question 192:

    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;

    double i=2;

    c1 = i;

    c1.print();

    return 0; }

    A. It prints: 0 0
    B. It prints: 1 1
    C. It prints: 2 0
    D. It prints: 2 2

  • Question 193:

    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;

    int z;

    A() { x=2; y=2; z=3; }

    A(int a, int b) : x(a), y(b) { z = x ? y;}

    void Print() {

    cout << z;

    }

    };

    int main () {

    A a(2,5);

    a.Print();

    return 0;

    }

    A. It prints: ?3
    B. It prints: 2
    C. It prints: 6
    D. It prints: 5

  • Question 194:

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

    #include

    #include

    using namespace std;

    class B;

    class A {

    int age; public:

    A () { age=5; };

    friend class B;

    };

    class B {

    string name;

    public:

    B () { name="Bob"; };

    void Print(A ob) {

    cout << name << ob.age;

    }

    };

    int main () {

    A a;

    B b;

    b.Print(a);

    return 0;

    }

    A. It prints: Bob5
    B. It prints: Bob
    C. It prints: 5
    D. None of these

  • Question 195:

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

    A. It prints: 0
    B. It prints: 3
    C. It prints: 2
    D. It prints: 1

  • Question 196:

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

    #include

    #include

    using namespace std;

    class complex{

    double re;

    double im;

    public:

    complex() : re(1),im(0.4) {}

    bool operator==(complex andt);

    };

    bool complex::operator == (complex andt){

    if((this?>re == t.re) andand (this?>im == t.im))

    return true;

    else

    return false;

    }

    int main(){

    complex c1,c2;

    if (c1==c2)

    cout << "OK";

    else {

    cout << "ERROR";

    }

    }

    A. It prints: OK
    B. It prints: ERROR
    C. Compilation error
    D. Runtime error.

  • Question 197:

    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;

    int z;

    A() { x=1; y=2; z=3; }

    A(int a, int b) : x(a), y(b) { z = x * y;}

    void Print() {

    cout << z;

    }

    };

    int main () {

    A a(2,5);

    a.Print();

    return 0;

    }

    A. It prints: 10
    B. It prints: 2
    C. It prints: 6
    D. It prints: 5

  • Question 198:

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

    #include

    using namespace std;

    int fun(int x) {

    return 2*x;

    }

    int main(){

    int i;

    i = fun(1) || fun(2);

    cout << i; return 0; }

    A. It prints: 0
    B. It prints: 1
    C. It prints: -1
    D. Compilation error

  • Question 199:

    If a function, which is not a method, needs to save any value between its subsequent invocations, this can be done by: (Choose two.)

    A. setting a variable declared inside the function with the static modifier
    B. setting a parameter of the function
    C. setting a variable declared outside the function
    D. setting a variable declared inside the function without the static modifier

  • Question 200:

    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;

    }

    A. It prints: 10
    B. It prints: 2
    C. It prints: 5
    D. It prints: 1

Tips on How to Prepare for the Exams

Nowadays, the certification exams become more and more important and required by more and more enterprises when applying for a job. But how to prepare for the exam effectively? How to prepare for the exam in a short time with less efforts? How to get a ideal result and how to find the most reliable resources? Here on Vcedump.com, you will find all the answers. Vcedump.com provide not only C++ Institute exam questions, answers and explanations but also complete assistance on your exam preparation and certification application. If you are confused on your CPA-21-02 exam preparations and C++ Institute certification application, do not hesitate to visit our Vcedump.com to find your solutions here.