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

    Which code, inserted at line 10, generate the output "50"?

    #include

    using namespace std;

    class Base {

    int age;

    public:

    Base () {

    age=5;

    };

    //insert code here

    void Print() { cout << age;}

    };

    void setAge(Base andob) {ob.age = 0;}

    int main () {

    Base a;

    a.Print();

    setAge(a);

    a.Print();

    return 0;

    }

    A. friend void setAge(Base ob);

    B. friend void setAge(Base *ob);

    C. friend void setAge(Base andob);

    D. None of these

  • Question 122:

    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[0]);

    return 0;

    }

    void fun(char *a) {

    cout << *a;

    }

    A. It prints: 01

    B. It prints: 1

    C. It prints: 0

    D. It prints: 0123

  • Question 123:

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

    A. It prints: 1

    B. It causes a compilation error

    C. It prints: -1

    D. It prints: 0

  • Question 124:

    What is the output of the program?

    #include

    using namespace std;

    class BaseC

    {

    int i;

    public:

    BaseC() { i=?1;}

    BaseC(int i) { i=i; }

    void seti(int a) { i = a; };

    void Print() { cout << i; }

    };

    int main()

    {

    BaseC *o = new BaseC();

    o?>seti(10);

    o?>Print();

    }

    A. It prints: 10

    B. It prints: ?1

    C. It prints: 0

    D. Compilation error

  • Question 125:

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

    A. It prints: 1

    B. It causes a compilation error

    C. It prints: -1

    D. It prints: 0

  • Question 126:

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

    A. It prints: 5.2110.0

    B. It prints: 5.210.0

    C. It prints: 52.10

    D. It prints: 5210

  • Question 127:

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

    A. It prints: 1

    B. lt prints: 2

    C. It prints: 111

    D. It prints: 121

  • Question 128:

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

    #include

    using namespace std;

    int main() {

    int i, j;

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

    for(j = i; j < i + 1; j++)

    if(j == i)

    continue;

    else

    break;

    }

    cout << j;

    return 0;

    }

    A. It prints: 0

    B. It prints: 3

    C. It prints: 2

    D. It prints: 1

  • Question 129:

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

    #include

    using namespace std;

    int op(int x, int y);

    float op(int x, float y);

    int main()

    {

    int i=1, j=2, k;

    float f=0.3;

    k = op(i, j);

    cout<< k << "," << op(0, f);

    return 0;

    }

    int op(int x, int y)

    {

    return x+y;

    }

    float op(int x, float y)

    {

    return x?y;

    }

    A. It prints: 3,1

    B. It prints: 3,?0.3

    C. It prints: 3,0

    D. It prints: 0,0

  • Question 130:

    Which code, inserted at line 10, generates the output "2?1"?

    #include

    #include

    using namespace std;

    class A {

    protected:

    int y;

    public:

    int z;

    };

    //insert code here

    public:

    void set() {

    y = 2;

    z = 3;

    }

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

    };

    int main () {

    B b;

    b.set();

    b.z

    = ?1; b.Print(); return 0; }

    A.

    class B : private A {

    B.

    class B : public A {

    C.

    class B : protected A {

    D.

    class B {

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.