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

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

    #include

    using namespace std;

    int main()

    {

    int i = 5;

    do {

    i??;

    cout<

    }

    while(i >= 0);

    return 0;

    }

    A. It prints: 43210?1

    B. It prints: ?1

    C. It prints: 4321

    D. It prints: 1

  • Question 182:

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

    #include

    #include

    using namespace std;

    class SampleClass

    {

    string *s;

    public:

    SampleClass() { s = new string("Text");}

    SampleClass(string s) { this?>s = new string(s);}

    ~SampleClass() { delete s;}

    void Print(){ cout<<*s;}

    };

    int main()

    {

    SampleClass *obj;

    obj = new SampleClass("Test");

    obj?>Print();

    }

    A. It prints: Text

    B. It prints: Test

    C. It prints: TextTest

    D. Garbage value.

  • Question 183:

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

    #include

    using namespace std;

    int main()

    {

    long int x,y=10;

    double d;

    d = 3.99;

    x=(int) d;

    cout << x <<", ";

    d=float (y);

    cout << d;

    return 0;

    }

    A. It prints: 3, 10

    B. It prints: 3.99, 10

    C. It prints: 4, 10.0

    D. It prints: 4, 10

  • Question 184:

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

    #include

    #include

    using namespace std;

    void fun(int i);

    int main()

    {

    int i=0;

    i++;

    for (i=0; i<=5; i++)

    {

    fun(i);

    }

    return 0;

    }

    void fun(int i)

    {

    if (i==3)

    return;

    cout << i;

    }

    A. It prints: 05

    B. It prints: 012345

    C. It prints: 01245

    D. It prints: 0

  • Question 185:

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

    #include

    using namespace std;

    class Base {

    int age;

    public:

    class C {

    int b;

    void PrintC() { cout << b; }

    };

    Base () {age=5;};

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

    void Print() { cout << age;}

    };

    int main () {

    Base a;

    a.setAge(10);

    a.Print();

    return 0;

    }

    A. It prints: 1020

    B. It prints: 105

    C. It prints: 10

    D. It prints: 20

  • Question 186:

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

    What happens if characters 'w', 'o', 'r', 'l' and 'd' are entered as input?

    #include

    #include

    using namespace std;

    int main()

    {

    string s1 = "Hello";

    string s2;

    getline( cin, s2 );

    cout << s1 + s2;

    return( 0 );

    }

    A. It prints: Helloworld

    B. It prints: Hello

    C. It prints: world

    D. Compilation error

  • Question 188:

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

    #include

    using namespace std;

    class First

    {

    public:

    First() { cout << "Constructor";}

    ~First() { cout << "Destructor";}

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

    };

    int main()

    {

    First FirstObject;

    FirstObject.Print();

    }

    A. It prints: Constructorfrom First

    B. It prints: Constructorfrom FirstDestructor

    C. It prints: Constructorfrom FirstDestructorDestructor

    D. Compilation error at line 16

  • Question 189:

    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;

    }

    A. 0

    B. 11

    C. ?10

    D. ?11

  • Question 190:

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

    A. It prints: MaxNiels

    B. It prints: RobertMax

    C. It prints: RobertNiels

    D. It causes a compilation error

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.