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

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

    #include

    #include

    using namespace std;

    class A {

    public:

    A() { cout << "A no parameters";}

    A(string s) { cout << "A string parameter";}

    A(A anda) { cout << "A object A parameter";}

    };

    class B : public A {

    public:

    B() { cout << "B no parameters";}

    B(string s) { cout << "B string parameter";}

    };

    int main () {

    A a1;

    A a2("Test");

    B b1("Alan");

    return 0;

    }

    A. It prints: A no parametersA string parameterA no parametersB string parameter

    B. It prints: A no parametersB string parameter

    C. It prints: B string parameter

    D. It prints: B no parameter

  • Question 232:

    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 << A::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 233:

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

    #include

    using namespace std;

    class A {

    public :

    void print() {

    cout << "A ";

    }

    };

    class B {

    public :

    void print() {

    cout << "B ";

    }

    };

    int main() {

    B sc[2];

    B *bc = (B*)sc;

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

    (bc++)->print();

    return 0;

    }

    A. It prints: A A

    B. It prints: B B

    C. It prints: A B

    D. It prints: B A

  • Question 234:

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

    public:

    int y;

    using A::x;

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

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

    };

    int main () {

    B b(5);

    b.Print();

    return 0;

    }

    A. It prints: 05

    B. It prints: 0

    C. It prints: 5

    D. It prints: 15

  • Question 235:

    What is the output of the program?

    #include

    using namespace std;

    #define PRINT(i) cout<

    int main()

    {

    int y=2, z=3;

    PRINT(y);

    PRINT(z);

    return 0;

    }

    A. It prints: 123

    B. It prints: 23

    C. It prints: 3

    D. It prints: 2

  • Question 236:

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

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

    using namespace std;

    int main()

    {

    int *a= new int;

    *a=100;

    cout << *a;

    delete a;

    }

    A. It prints: 1

    B. It prints: 100

    C. It prints: 0

    D. It prints: 10

  • Question 238:

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

    #include

    using namespace std;

    int fun(int);

    int main()

    {

    int *x = new int;

    *x=10;

    //insert code here

    return 0;

    }

    int fun(int i)

    {

    return i*i;

    }

    A. cout << fun(*x) ;

    B. cout << fun(10);

    C. cout << fun(5) ;

    D. cout << fun(y) ;

  • Question 239:

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

    A. It prints: 3

    B. It prints: 4

    C. It prints: 0

    D. It prints: 6

  • Question 240:

    What is the output of the program?

    #include

    #include

    using namespace std;

    struct t

    {

    int tab[2];

    };

    class First

    {

    struct t u;

    public:

    First() {

    u.tab[0] = 1;

    u.tab[1] = 0;

    }

    void Print(){

    cout << u.tab[0] << " " << u.tab[1];

    }

    };

    int main()

    {

    First t;

    t.Print();

    }

    A. It prints: 2 2

    B. It prints: 1 1

    C. It prints: 1 0

    D. It prints: 0 0

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.