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

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

    What will the variable "age" 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 93:

    What will be the output of the program?

    #include

    #include

    using namespace std;

    int fun(int);

    int main()

    {

    float k=3;

    k = fun(k);

    cout<

    return 0;

    }

    int fun(int i)

    {

    i++;

    return i;

    }

    A. 3
    B. 5
    C. 4
    D. 5

  • Question 94:

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

    #include

    using namespace std;

    class Base {

    int age;

    public:

    class C {

    int b;

    void PrintC() { cout << b; }

    };

    Base () {age=5;};

    void setAge(int a=20) {age = a;}

    void Print() { cout << age;}

    };

    int main () {

    Base a;

    a.setAge(10);

    a.Print();

    return 0;

    }

    A. It prints: 1020
    B. It prints: 105
    C. It prints: 10
    D. It prints: 20

  • Question 95:

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

    #include

    using namespace std;

    class A {

    public:

    int x;

    A() { x=0;}

    };

    class B : public A {

    public:

    B() { x=1;}

    };

    class C : private B {

    public:

    C() { x=2;}

    };

    int main () {

    C c1;

    cout << c1.x;

    return 0;

    }

    A. It prints: 210
    B. It prints: 110
    C. It prints: 010
    D. Compilation error

  • Question 96:

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

    #include

    using namespace std;

    struct {

    int x;

    char c;

    union {

    float f;

    int i;

    };

    } s;

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

    {

    s.x=10;

    s.i=0;

    cout << s.i << " " << s.x;

    }

    A. It prints: 0 10
    B. It prints: 11
    C. Compilation error
    D. None of these

  • Question 97:

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

    A. It causes a compilation error
    B. It prints: Tesc failed
    C. .It prints: failed
    D. It prints: Tesc

  • Question 98:

    Which statement should be added in the following program to make work it correctly?

    using namespace std;

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

    {

    cout<<"Hello";

    }

    A. #include
    B. #include
    C. #include
    D. #include

  • Question 99:

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

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

    A. It prints: BAD
    B. It prints: BACD
    C. It prints: ABCD
    D. It prints: BAC

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.