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

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

    A. It prints: 1
    B. It causes a compilation error
    C. It prints: 0
    D. It prints: My exception,

  • Question 132:

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

    #include

    using namespace std;

    int main()

    {

    int *t; t = new int[2];

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

    t[i]=0;

    }

    cout << t[1];

    }

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

  • Question 133:

    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 : public A {

    string name;

    public:

    void set() {

    y = 2;

    z = 3;

    }

    void Print() { cout << y << z; }

    };

    int main () {

    B b;

    b.set();

    b.Print();

    return 0;

    }

    A. It prints: 123
    B. It prints: 000
    C. It prints: 23
    D. It prints: 12

  • Question 134:

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

    #include

    using namespace std;

    int op(int x, int y)

    {

    int i;

    i = x + y;

    return i;

    }

    int main()

    {

    int i=1, j=2, k, l;

    k = op(i, j);

    l = op(j, i);

    cout<< k << "," << l;

    return 0;

    }

    A. It prints: 1,2
    B. It prints: ?1,1
    C. It prints: 1,1
    D. It prints: 3,3

  • Question 135:

    Which code, inserted at line 5, generates the output "ABC"?

    #include

    using namespace std;

    class A {

    public:

    //insert code here

    };

    class B:public A {

    public:

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

    };

    class C:public B {

    public:

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

    };

    int main()

    {

    B ob2;

    C ob3;

    A *obj;

    obj = andob1;

    obj?>Print();

    obj = andob2;

    obj?>Print();

    obj = andob3;

    obj?>Print();

    }

    A. void Print(){ cout
    B. virtual void Print(){ cout
    C. virtual void Print(string s){ cout
    D. None of these

  • Question 136:

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

    #include

    using namespace std;

    int main()

    {

    int i=2;

    switch(i)

    {

    case 1:

    cout<<"Hello";

    case 2:

    cout<<"world";

    case 3:

    cout<<"End";

    } return 0;

    }

    A. It prints: Hello
    B. It prints: world
    C. It prints: worldEnd
    D. It prints: End

  • Question 137:

    What will be the output of the program?

    #include

    using namespace std;

    int main()

    {

    int i=0;

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

    cout << i;

    return 0;

    }

    A. 012345
    B. 0123
    C. 5
    D. 6

  • Question 138:

    How many times will the program print "HELLO" ?

    #include

    using namespace std;

    int main()

    {

    cout<<"HELLO";

    main();

    return 0;

    }

    A. 65536
    B. 32769
    C. 1
    D. Till stack overflows

  • Question 139:

    What will the variable "y" be in class B?

    class A {

    int x;

    protected:

    int y;

    public:

    int age;

    };

    class B : private A {

    string name;

    public:

    void Print() {

    cout << name << age;

    }

    };

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

  • Question 140:

    What is the output of the program?

    #include

    #include

    using namespace std;

    int main () {

    string s1 = "Hello", s2 = "World";

    s2 = s1 + s2;

    cout << s2;

    return 0;

    }

    A. It prints: Hello
    B. It prints: HelloWorld
    C. It prints: WorldHello
    D. It prints: WorldHelloWorld

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.