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

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

    public:

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

    };

    class C:public B {

    public:

    void Print(){ cout<< "C";}

    };

    int main()

    {

    A ob1;

    B ob2;

    C ob3;

    B *obj;

    obj = andob2;

    obj?>Print();

    obj = andob3;

    obj?>Print();

    }

    A. It prints: BB
    B. It prints: AA
    C. It prints: BC
    D. It prints: AB

  • Question 222:

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

    #include

    using namespace std;

    int getValue();

    int main()

    {

    const int x = getValue();

    cout<

    return 0;

    }

    int getValue()

    {

    return 5;

    }

    A. It will print 0
    B. The code will not compile.
    C. It will print 5
    D. It will print garbage value

  • Question 223:

    What is the output of the program given below?

    #include

    using namespace std;

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

    {

    float f=?10.501;

    cout<<(int)f;

    }

    B. 11
    C. ?10
    D. ?11

  • Question 224:

    What is the output of the program?

    #include

    #include

    using namespace std;

    class First

    {

    string name;

    public:

    First() {

    name = "Alan";

    }

    void setName(string n) {this?>name = n;}

    void setName() {this?>name = "John";}

    void Print(){

    cout << name;

    }

    };

    int main()

    {

    First ob1,*ob2;

    ob2 = new First();

    First *t;

    t = andob1;

    t?>setName();

    t?>Print();

    t = ob2;

    t?>setName("Steve");

    ob2?>Print();

    }

    A. It prints: JohnSteve
    B. It prints: AlanAlan
    C. It prints: AlanSteve
    D. It prints: JohnAlan

  • Question 225:

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

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

    #include

    using namespace std;

    class A {

    public:

    int x;

    };

    class B : public A {

    public:

    B() { x=1;}

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

    };

    int main () {

    B c1;

    B c2(10);

    cout << c1.x;

    cout << c2.x;

    return 0;

    }

    A. It prints: 010
    B. It prints: 110
    C. It prints: 00
    D. It prints: 1

  • Question 227:

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

    #include

    #include

    using namespace std;

    class A {

    public:

    A() { cout << "A0 ";}

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

    };

    class B : public A {

    public:

    B() { cout << "B0 ";}

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

    };

    class C : private B {

    public:

    C() { cout << "C0 ";}

    C(string s) { cout << "C1 ";}

    };

    int main () {

    B b1;

    C c1;

    return 0;

    }

    A. It prints: A0 B0 A0 B1 A0 C0 A0 C1
    B. It prints: B0 B1 C0 C1
    C. It prints: A0 B0 A0 B0 C0
    D. It prints: B0 B1

  • Question 228:

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

    A. using namespace myNamespace1; using namespace myNamespace2;
    B. using namespace myNamespace1;
    C. using namespace myNamespace1::y; using myNamespace2::x;
    D. using namespace myNamespace2::y; using myNamespace1::x;

  • Question 229:

    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 {

    void print() {

    cout << "B ";

    }

    };

    int main() {

    B sc[2];

    A *bc = (A*)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 230:

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

    A. It prints: 3.14
    B. It prints: Scring
    C. It causes a compilation error
    D. It prints: x

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.