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

    What is the output of the program given below?

    #include

    using namespace std;

    int main (int argc, const char * argv[])

    {

    int i=10;

    {

    int i=0;

    cout<

    }

    {

    i=5;

    cout << i;

    }

    cout<

    return 0;

    }

    A. 1010
    B. 101010
    C. 055
    D. None of these

  • Question 162:

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

    A. It prints: 1
    B. lt prints: 2
    C. It prints: 111
    D. It prints: 121

  • Question 163:

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

    A. It prints: 4
    B. It prints: 1
    C. It causes a compilation error
    D. lit prints: 0

  • Question 164:

    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;

    }

    };

    A. public
    B. private
    C. protected
    D. None of these

  • Question 165:

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

    #include

    using namespace std;

    class A

    {

    public:

    void Print(){ cout<<"A";}

    };

    class B:public A

    {

    public:

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

    };

    int main()

    {

    A *obj;

    A ob1;

    obj = andob1;

    obj?>Print();

    B ob2;

    obj = andob2;

    obj?>Print();

    }

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

  • Question 166:

    Point out an error in the program.

    #include

    using namespace std;

    int main()

    {

    const int x=1;

    int const *y=andx;

    cout<<*y;

    return 0;

    }

    A. No error
    B. Error: unknown pointer conversion
    C. cannot convert from 'const int *' to 'int *const'
    D. Compilation error

  • Question 167:

    Which code, inserted at line 18, generates the output "AB"

    #include

    using namespace std;

    class A

    {

    public:

    void Print(){ cout<< "A";}

    void Print2(){ cout<< "a";}

    };

    class B:public A

    {

    public:

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

    void Print2(){ cout<< "b";}

    };

    int main()

    {

    B ob2;

    //insert code here

    ob2.Print();

    }

    A. ob2?>A::Print();
    B. ob2.B::Print();
    C. ob2?>B::Print();
    D. ob2.A::Print();

  • Question 168:

    What is the output of the program if character 2 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;

    }

    }

    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.
    B. It prints: int exception. Exception Nr. 20
    C. It prints: An exception occurred
    D. It prints: float exception. Exception Nr. 5.2

  • Question 169:

    Which code, inserted at line 19, generates the output "23"?

    #include

    #include

    using namespace std;

    class A {

    int x;

    protected:

    int y;

    public:

    int z;

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

    };

    class B : public A {

    string z;

    public:

    int y;

    void set() { y = 4; z = "John"; }

    void Print() {

    //insert code here

    }

    };

    int main () {

    B b;

    b.set();

    b.Print();

    return 0;

    }

    A. cout
    B. cout
    C. cout
    D. cout

  • Question 170:

    How many copies of the value member are stored in memory during program execution?

    A. as many as objects of the A class plus one
    B. as many as obiects of the A class and its inheritants
    C. as many as objects of the A class
    D. one

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.