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

    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;}

    A(int x) { this?>x=x;}

    };

    class B : private A {

    public:

    using A::x;

    B() { x=1;}

    B(int x) {this?>x = x;}

    };

    int main () {

    B c1;

    B c2(?5);

    cout << c1.x;

    cout << c2.x;

    return 0;

    }

    A. It prints: 5

    B. It prints: 1?5

    C. It prints: 05

    D. It prints: 0

  • Question 92:

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

    #include

    using namespace std;

    void fun(char*);

    int main()

    {

    char t[4]={'0', '1', '2', '3'};

    fun(andt[2]);

    return 0;

    }

    void fun(char *a)

    {

    cout << *a;

    }

    A. It prints: 2

    B. It prints: 21

    C. It prints: 00

    D. It prints: 02

  • Question 93:

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

    #include

    using namespace std;

    int x=5;

    static int y;

    int i=0;

    void static myFunction()

    {

    y=x++ + ++i;

    }

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

    {

    x++;

    myFunction();

    cout<

    }

    A. Compilation fails

    B. It prints: 5 5 0

    C. It prints: 7 7 1

    D. It prints: 6 5 1

  • Question 94:

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

    #include

    #include

    using namespace std;

    int f(int i, int b);

    int main()

    {

    int i=0;

    i++;

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

    {

    cout<

    }

    return 0;

    }

    int f(int a, int b)

    {

    return a+b;

    }

    A. It prints: 202020

    B. It prints: 012

    C. It prints: 0

    D. It prints: 2

  • Question 95:

    Which code, inserted at line 8, generates the output "0102020"?

    #include

    using namespace std;

    static int age;

    public:

    Base () {};

    ~Base () {};

    //insert code here

    void Print() { cout << age;}

    };

    int Base::age=0;

    int main () {

    Base a,*b;

    b = new Base();

    a.Print();

    a.setAge(10);

    a.Print();

    b?>setAge();

    a.Print();

    b?>Print();

    return 0;

    }

    A. void setAge(int a) {age = a;}

    B. void setAge() {age = 20;}

    C. void setAge() {age = 10;}

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

  • Question 96:

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

    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;

    int z;

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

    A(int a, int b) : x(a), y(b) { z = x ? y;}

    void Print() {

    cout << z;

    }

    };

    int main () {

    A a(2,5);

    a.Print();

    return 0;

    }

    A. It prints: ?3

    B. It prints: 2

    C. It prints: 6

    D. It prints: 5

  • Question 98:

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

    #include

    #include

    using namespace std;

    inline float sum(float a,float b)

    {

    return a+b;

    }

    int main()

    {

    float a,b;

    a = 1.5; b = 3.4;

    cout<

    return 0;

    }

    A. It prints: 0

    B. It prints: 4.9

    C. It prints: 5

    D. It prints: 4

  • Question 99:

    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<<"A";}

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

    C. virtual void Print(string s){ cout<

    D. None of these

  • Question 100:

    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

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.