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

    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;

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

    };

    class B : public A {

    string z;

    public:

    void set() {

    y = 4;

    z = "John";

    }

    void Print() {

    cout << y << z;

    }

    };

    int main () {

    B b;

    b.set();

    b.Print();

    return 0;

    }

    A. It prints: 4John
    B. It prints: 2John
    C. It prints: 23
    D. It prints: 43

  • Question 152:

    What is the output of the program?

    #include

    #include

    using namespace std;

    int main()

    {

    string s1[]= {"Hello" , "World" };

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

    cout << s1[i];

    }

    return( 0 );

    }

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

  • Question 153:

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

    #include

    #include

    using namespace std;

    class First

    {

    string *s;

    public:

    First() { s = new string("Text");}

    ~First() { delete s;}

    void Print(){ cout<<*s;}

    };

    int main()

    {

    First FirstObject;

    FirstObject.~First();

    }

    A. It prints: Text
    B. Compilation error
    C. Runtime error.
    D. None of these

  • Question 154:

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

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

    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(2), y(2), z(1) { z = x + y; }

    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;

    b.Print();

    return 0;

    }

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

  • Question 157:

    Which of the following is a logical operator?

    A. and
    B. andand
    C. ||
    D. !

  • Question 158:

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

    #include

    #include

    using namespace std;

    int fun(int);

    int main()

    {

    int *x = new int;

    *x=10;

    cout << fun(*x);

    return 0;

    }

    int fun(int i)

    {

    return i*i;

    }

    A. It will print: 100
    B. It will print: 101
    C. It will print: 10
    D. It will print: 1

  • Question 159:

    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;

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

    };

    class B : public A {

    public:

    void set() {

    y = 4; z = 2;

    }

    void Print() {

    cout << y << z;

    }

    };

    int main () {

    B b;

    b.set();

    b.Print();

    return 0;

    }

    A. It prints: 42
    B. It prints: 44
    C. It prints: 22
    D. It prints: 2

  • Question 160:

    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) { z = x + y; }

    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;

    b.Print();

    return 0;

    }

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

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.