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 111:

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

    #include

    using namespace std;

    class First

    {

    public:

    virtual void Print(){ cout<<"from First";}

    };

    class Second:public First

    {

    public:

    void Print(){ cout<< "from Second";}

    };

    void fun(First *obj);

    int main()

    {

    First FirstObject;

    fun(andFirstObject);

    Second SecondObject;

    fun(andSecondObject);

    }

    void fun(First *obj)

    {

    obj?>Print();

    }

    A. It prints: from First
    B. It prints: from Firstfrom First
    C. It prints: from Firstfrom Second
    D. It prints: from Secondfrom Second

  • Question 112:

    Which definitions are correct?

    A. int age;
    B. int double;
    C. char c;
    D. int char;

  • Question 113:

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

    #include

    using namespace std;

    class First

    {

    public:

    First() { cout << "Constructor";}

    ~First() { cout << "Destructor";}

    void Print(){ cout<<"from First";}

    };

    int main()

    {

    First FirstObject;

    FirstObject.Print();

    }

    A. It prints: Constructorfrom First
    B. It prints: Constructorfrom FirstDestructor
    C. It prints: Constructorfrom FirstDestructorDestructor
    D. Compilation error at line 16

  • Question 114:

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

    #include

    using namespace std;

    class A

    {

    public:

    virtual void Print()=0;

    };

    class B:public A

    {

    public:

    virtual void Print(){ cout<< "B";}

    };

    int main()

    {

    B ob2;

    A *obj;

    obj = andob2;

    obj?>Print();

    }

    A. It prints: B
    B. It prints: A
    C. It prints: AB
    D. It prints: BA

  • Question 115:

    What is the output of the program if character "1" is supplied as input?

    #include

    using namespace std;

    int main () {

    int c;

    cin >> c;

    try

    {

    switch (c)

    {

    case 1:

    throw 20;

    case 2:

    throw 5.2f;

    case 3:

    throw 'a';

    }

    }

    catch (int e)

    { cout << "int exception. Exception Nr. " << e; }

    catch (float e)

    { cout << "float exception. Exception Nr. " << e; }

    catch (...)

    { cout << "An exception occurred."; }

    return 0; }

    A. It prints: float exception. Exception Nr. 5.2
    B. It prints: int exception. Exception Nr. 20
    C. It prints: An exception occurred
    D. Compilation Error

  • Question 116:

    What is the output of the program?

    #include

    #include

    using namespace std;

    union t

    {

    char c;

    int i;

    };

    class First

    {

    union t u;

    public:

    First() {

    u.c

    = 'A';

    }

    void Print(){

    cout << u.c;

    }

    };

    int main()

    {

    First *t = new First();

    t?>Print();

    }

    A. Garbage value
    B. It prints: A
    C. It prints: A 65
    D. Compilation error

  • Question 117:

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

    #include

    #include

    using namespace std;

    class A {

    int x;

    protected:

    int y;

    public:

    int z;

    };

    class B : private A {

    string name;

    public:

    void set() {

    x = 1;

    }

    void Print() {

    cout << x;

    }

    };

    int main () {

    B b;

    b.set();

    b.Print();

    return 0;

    }

    A. It prints: 123
    B. It prints: 1
    C. It prints: ?123
    D. Compilation error

  • Question 118:

    Which code line inserted instead of the comment below will fix the program so that it produces the expected output and does not cause any memory leak?

    A. delete [] p;
    B. delete p[];
    C. delete p;
    D. delete *p;

  • Question 119:

    Which code, inserted at line 14, generates the output "3.14 10"?

    #include

    using namespace std;

    namespace myNamespace1

    int x = 5;

    int y = 10;

    } namespace myNamespace2 { float x = 3.14; float y = 1.5; } int main () { //insert code here cout << x << " " << y; return 0; }

    A. using myNamespace2::y; using myNamespace1::x;
    B. using namespace myNamespace1;
    C. using namespace myNamespace1; using namespace myNamespace2;
    D. using myNamespace1::y; using myNamespace2::x;

  • Question 120:

    How many times will "HELLO" be printed?

    #include

    using namespace std;

    int main()

    {

    for(int i=?1; i<=10; i++)

    {

    if(i < 5)

    continue;

    else

    break;

    cout<<"HELLO";

    }

    return 0;

    }

    A. 1
    B. 2
    D. 20

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.