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

    Which code line inserted instead of the comment below will cause the program to produce the expected output?

    A. ob2.A::print();

    B. ob2 ?gt; A::print();

    C. ob2.B::print();

    D. ob2 ?gt; B::print();

  • Question 222:

    Which of the following is a correct way to define the function fun() in the program below?

    #include

    #include

    #include

    using namespace std;

    int main()

    {

    int a[2][2];

    fun(a);

    return 0;

    }

    A. void fun(int *p[2]) {}

    B. void fun(int *p[2][2]) {}

    C. void fun(int *p[][2]) {}

    D. void fun(int p[][2]) {}

  • Question 223:

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

    #include

    using namespace std;

    class Base {

    static int age;

    public:

    Base () {};

    ~Base () {};

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

    void Print() { cout << age;}

    };

    int Base::age=0;

    int main () {

    Base a;

    a.setAge(10);

    a.Print();

    a.setAge();

    a.Print();

    return 0;

    }

    A. It prints: 10

    B. It prints: 20

    C. It prints: 1020

    D. It prints: 2010

  • Question 224:

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

    #include

    #include

    using namespace std;

    int main()

    {

    string s1[]= {"H" , "t" };

    string s;

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

    s = s1[i];

    s.insert(1,"o");

    cout << s;

    }

    return( 0 );

    }

    A. It prints: Hoto

    B. It prints: Ho

    C. It prints: to

    D. It prints: Ht

  • Question 225:

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

    #include

    using namespace std;

    class First

    {

    public:

    virtual void Print(){ cout<<"from First";}

    };

    class Second:public First

    {

    public:

    void Print(){ cout<< "from Second";}

    };

    void fun(First *obj);

    int main()

    {

    First FirstObject;

    fun(andFirstObject);

    Second SecondObject;

    fun(andSecondObject);

    }

    void fun(First *obj)

    {

    obj?>Print();

    }

    A. It prints: from First

    B. It prints: from Firstfrom First

    C. It prints: from Firstfrom Second

    D. It prints: from Secondfrom Second

  • Question 226:

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

    #include

    using namespace std;

    int main()

    {

    union un

    {

    int x;

    char c;

    };

    union un u1 = {10};

    union un u2 = {'a'};

    union un u3 = {20, 'a'};

    cout<

    cout<

    cout<

    return 0;

    }

    A. It prints: 10aa

    B. It prints: 10a20a

    C. It prints: 1a

    D. Compilation error

  • Question 227:

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

    #include

    using namespace std;

    int fun(int x) {

    return 2*x;

    }

    int main(){

    int i;

    i = fun(1) || fun(2);

    cout << i;

    return 0;

    }

    A. It prints: 0

    B. It prints: 1

    C. It prints: -1

    D. Compilation error

  • Question 228:

    Which of the following statements are true? (Choose two.)

    A. Class A's friend's friend is also a friend of class A

    B. Friendship is inherited

    C. A class may be a friend of many classes

    D. A class may have many friends

  • Question 229:

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

    #include

    using namespace std;

    namespace myNamespace1

    {

    int x = 5;

    int y = 10;

    }

    namespace myNamespace2

    {

    float x = 3.14;

    float y = 1.5;

    }

    int main () {

    namespace newname = myNamespace1;

    using namespace newname;

    cout << x << " ";

    cout << y;

    return 0;

    }

    A. It prints: 5 1.5

    B. It prints: 3.14 1.5

    C. It prints: 5 10

    D. It prints: 5

  • Question 230:

    What is not inherited from the base class?

    A. constructor

    B. destructor

    C. operator=()

    D. operator+()

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.