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

    Which code, inserted at line 15, generates the output "5 Bob"?

    #include

    using namespace std;

    class B;

    class A {

    int age;

    public:

    A () { age=5; };

    friend void Print(A andob, B andso);

    };

    class B {

    string name;

    public:

    B () { name="Bob"; };

    //insert code here

    };

    void Print(A andob, B andso) {

    cout<

    }

    int main () {

    A a;

    B b;

    Print(a,b);

    return 0;

    }

    A. friend void Print(A ob, B so);
    B. friend void Print(A andob, B andso);
    C. friend void Print(A *ob, B *so);
    D. None of these

  • Question 232:

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

    using namespace std;

    int main()

    {

    int a=5;

    cout << ((a < 5) ? 9.9 : 9);

    }

    A. It prints: 9
    B. It prints: 9.9
    C. Compilation error
    D. None of these

  • Question 233:

    Which of the following statements may completely ignore their bodies (inner statements)? (Choose three.)

    A. do
    B. swicch
    C. for
    D. while

  • Question 234:

    What is the expected output of the following program?

    A. It prints: 432
    B. It prints: 321
    C. It prints: 4321
    D. It prints: 3210

  • Question 235:

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

    #include

    #include

    #include

    using namespace std;

    int main(void)

    {

    string s;

    s = "Test";

    s.resize (s.size() ? 1);

    cout<

    return 0;

    }

    A. It prints: Test 4
    B. It prints: Test 3
    C. Compilation error
    D. It prints: Tes 3

  • Question 236:

    What is the output of the program?

    #include

    #include

    using namespace std;

    struct Person {

    int age;

    };

    class First

    {

    Person *person;

    public:

    First() {person = new Person;

    person?>age = 20;

    }

    void Print(){

    cout << person?>age;

    }

    };

    int main()

    {

    First t[2];

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

    t[i].Print();

    }

    A. It prints: 10
    B. It prints: 2020
    C. It prints: 22
    D. It prints: 00

  • Question 237:

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

    using namespace std;

    int min(int a, int b);

    int main()

    {

    int b=10;

    b = min(5,20);

    cout << b;

    return 0;

    }

    int min(int a, int b)

    {

    if (a

    return(a);

    else

    return(b);

    }

    A. It prints: 10
    B. It prints: 20
    C. It prints: 5
    D. It prints: 0

  • Question 238:

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

    #include

    using namespace std;

    class BaseC

    {

    public:

    int *ptr;

    BaseC() { ptr = new int(10);}

    BaseC(int i) { ptr = new int(i); }

    ~BaseC() { delete ptr; }

    };

    void fun(BaseC x);

    int main()

    {

    BaseC *o = new BaseC(5);

    fun(*o);

    }

    void fun(BaseC x) {

    cout << "Hello:"<<*x.ptr;

    }

    A. It prints: Hello:50
    B. It prints: Hello:10
    C. It prints: Hello:5
    D. Compilation error

  • Question 239:

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

    #include

    using namespace std;

    class First

    {

    public:

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

    };

    class Second

    {

    public:

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

    };

    int main()

    {

    Second t[2];

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

    t[i].Print();

    }

    A. It prints: from First
    B. It prints: from Firstfrom First
    C. It prints: from Secondfrom Second
    D. It prints: from Second

  • Question 240:

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

    #include

    using namespace std;

    int s(int n);

    int main()

    {

    int a;

    a = 3;

    cout << s(a);

    return 0;

    }

    int s(int n)

    {

    if(n == 0) return 1;

    return s(n?1)*n;

    }

    A. It prints: 4
    B. It prints: 6
    C. It prints: 3
    D. It prints: 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.