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
    :Jul 18, 2025

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

  • Question 131:

    What is the output of the program given below?

    #include

    using namespace std;

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

    {

    enum state { ok, error, warning};

    enum state s1, s2, s3, s4;

    s1 = ok;

    s2 = warning;

    s3 = error;

    s4 = ok;

    cout << s1<< s2<< s3<< s4;

    return 0;

    }

    A. 1234

    B. compilation fails

    C. 0210

    D. 1322

  • Question 132:

    What happens if you try to compile and run this program?

    #include

    using namespace std;

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

    {

    print("Test");

    return 0;

    }

    void print(int c[])

    {

    cout<

    }

    A. It prints: Test

    B. Compilation fails

    C. Program terminates abnormally

    D. None of these

  • Question 133:

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

    #include

    #include

    using namespace std;

    struct Person {

    string name;

    int age;

    };

    class First

    {

    Person *person;

    public:

    First() {person = new Person;

    person?>name = "John";

    person?>age = 30;

    }

    void Print(){

    cout<name << " "<< person?>age;

    }

    };

    int main()

    {

    First t[2];

    for (int i=0; i<2; i++)

    t[i].Print();

    }

    A. It prints: 30

    B. It prints: John

    C. It prints: John 31

    D. It prints: John 30John 30

  • Question 134:

    What is the output of the program?

    #include

    #include

    using namespace std;

    int main()

    {

    char str[] = "Hello\0\World\0";

    cout << str;

    return 0;

    }

    A. It prints: Hello

    B. It prints: World

    C. It prints: HW

    D. It prints: World\0World

  • Question 135:

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

    #include

    using namespace std;

    class A {

    public:

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

    };

    class C:public A {

    public:

    virtual void Print()=0;

    };

    int main()

    {

    C obj3;

    obj3?>Print();

    }

    A. It prints: BB

    B. It prints: A

    C. It prints: AB

    D. Compilation error

  • Question 136:

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

    #include

    using namespace std;

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

    {

    int tab[5]={1,2,3};

    for (int i=0; i<5; i++)

    cout <

    return 0;

    }

    A. compilation fails

    B. It prints: 12300

    C. It prints: 12345

    D. It prints: 00000

  • Question 137:

    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:

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

    };

    class C:public B {

    public:

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

    };

    int main()

    {

    A ob1;

    B ob2;

    C ob3;

    B *obj;

    obj = andob2;

    obj?>Print();

    obj = andob3;

    obj?>Print();

    }

    A. It prints: BB

    B. It prints: AA

    C. It prints: BC

    D. It prints: AB

  • Question 138:

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

    #include

    using namespace std;

    class First

    {

    public:

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

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

    };

    int main()

    {

    First FirstObject;

    FirstObject.Print();

    }

    A. It prints: Constructorfrom First

    B. It prints: Constructor

    C. It prints: from First

    D. None of these

  • Question 139:

    Which line of code inserted instead of the comment will make the following code run properly without causing memory leaks?

    A. ~Base() ( delete this; }

    B. no additional code is needed

    C. ~Base() { delete ptr; delete ptr; }

    D. ~Base() { delete ptr; }

  • Question 140:

    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

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.