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

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

    #include

    using namespace std;

    void set(struct person*);

    struct person

    {

    int age;

    };

    int main()

    {

    struct person e = {18};

    set(ande);

    cout<< e.age;

    return 0;

    }

    void set(struct person *p)

    {

    p?>age = p?>age + 1;

    }

    A. It prints: 18

    B. It prints: 19

    C. It prints: 20

    D. It prints: 0

  • Question 2:

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

    #include

    using namespace std;

    int main()

    {

    int x=2, *y, z=3;

    y = andz;

    cout<

    return 0;

    }

    A. It prints: 36

    B. It prints: 14

    C. It prints: 16

    D. Compilation error

  • Question 3:

    What is the output of the program?

    #include

    using namespace std;

    int main()

    {

    int tab[4]={10,20,30,40};

    tab[1]=10;

    int *p;

    p=andtab[0];

    cout<<*p;

    return 0;

    }

    A. It prints: 10

    B. It prints: 20

    C. It prints: 11

    D. It prints: 30

  • Question 4:

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

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

    #include

    #include

    using namespace std;

    class A {

    public:

    int x;

    A() { x=0;}

    };

    class B {

    public:

    int x;

    B() { x=1;}

    };

    class C :public A, public B {

    public:

    int x;

    C(int x) {

    this?>x = x;

    A :x = x + 1;

    }

    void Print() { cout << x << A::x << B::x; }

    };

    int main () {

    C c2(1);

    c2.Print();

    return 0;

    }

    A.

    It prints: 1

    B.

    It prints: 121

    C.

    It prints: 111

    D.

    It prints: 2

  • Question 6:

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

    #include

    using namespace std;

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

    {

    int x,y;

    union t

    {

    char tab[2];

    int i;

    };

    union t u;

    u.tab[0] = 1;

    u.tab[1] = 2;

    u.i

    = 0;

    x = u.tab[0];

    y = u.tab[1];

    cout << x << "," << y << "," << u.i;

    return 0;

    }

    A.

    compilation fails

    B.

    It prints: 0,0,0

    C.

    It prints: 1,2,0

    D.

    None of these

  • Question 7:

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

    #include

    using namespace std;

    int main()

    {

    int x=2, *y;

    y = andx;

    cout << *y + x;

    return 0;

    }

    A. It prints: 1

    B. It prints: 2

    C. It prints: 4

    D. It prints: 0

  • Question 8:

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

    #include

    using namespace std;

    int main()

    {

    int x=0;

    int *ptr;

    ptr = andx;

    cout<

    return 0;

    }

    A. It prints: 0 0

    B. It prints address of ptr

    C. It prints: 1

    D. It prints: 2

  • Question 9:

    Which of the following statements are correct about an array? int tab[10];

    A. The array can store 10 elements.

    B. The expression tab[1] designates the very first element in the array.

    C. The expression tab[9] designates the last element in the array.

    D. It is necessary to initialize the array at the time of declaration.

  • Question 10:

    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

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.