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
    :Jul 11, 2026

C++ Institute CPA-21-02 Online Questions & Answers

  • Question 1:

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

    #include

    using namespace std;

    int main()

    {

    const int x=0;

    const int *ptr;

    ptr = andx;

    cout<<*ptr;

    return 0;

    }

    A. It prints: 0
    B. It prints address of x
    C. It prints: 1
    D. Compilation error

  • Question 2:

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

    #include

    using namespace std;

    #define FUN(arg) if(arg) cout<<"Test";

    int main()

    {

    int i=1;

    FUN(i<3);

    return 0;

    }

    A. It prints: 0
    B. It prints: T
    C. It prints: T0
    D. It prints: Test

  • Question 3:

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

    #include

    #include

    using namespace std;

    int f(int i, int b);

    int main()

    {

    int i=0;

    i++;

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

    {

    cout<

    }

    return 0;

    }

    int f(int a, int b)

    {

    return a+b;

    }

    A. It prints: 202020
    B. It prints: 012
    C. It prints: 0
    D. It prints: 2

  • Question 4:

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

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

    #include

    #include

    using namespace std;

    class myClass : public exception

    {

    virtual const char* what() const throw()

    {

    return "My exception.";

    }

    } obj;

    int main () {

    try

    {

    throw obj;

    }

    catch (exceptionand e)

    {

    cout << e.what() << endl;

    }

    return 0;

    }

    A. It prints: My exception.
    B. It prints: 0
    C. It prints: 1
    D. Compilation error

  • Question 6:

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

    #include

    using namespace std;

    int main()

    {

    const char *s;

    char str[] = "Hello ";

    s = str;

    while(*s) {

    cout << *++s;

    *s++;

    }

    return 0;

    }

    A. It will print:"el "
    B. The code will not compile.
    C. It will print:"Hello "
    D. It will print garbage value

  • Question 7:

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

    #include

    using namespace std;

    int main()

    {

    int i=5;

    switch(i)

    {

    case 1:

    cout<<"Hello";

    break;

    case 2:

    cout<<"world";

    break;

    case 3:

    break;

    default:

    cout<<"End";

    }

    return 0;

    }

    A. It prints: Hello
    B. It prints: world
    C. It prints: End
    D. It prints: Helloworld

  • Question 8:

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

    #include

    using namespace std;

    int x=5;

    static int y=0;

    void myFunction(int a)

    {

    y=++a;

    }

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

    {

    int i=0;

    myFunction(i);

    cout<

    }

    A. It prints: 0 5
    B. It prints: 5 1
    C. It prints: 1 5
    D. It prints: 5 0

  • Question 9:

    What is the output of the program?

    #include

    using namespace std;

    class Base {

    static int age;

    public:

    Base () {};

    ~Base () {};

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

    void Print() { cout << age;}

    };

    int Base::age=0;

    int main () {

    Base a,*b;

    b = new Base();

    a.setAge();

    b?>setAge(20);

    a.Print();

    b?>Print();

    return 0;

    }

    A. It prints: 2020
    B. It prints: 1020
    C. It prints: 20
    D. It prints: 10

  • Question 10:

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

    #include

    #include

    using namespace std;

    class A {

    public:

    A() { cout << "A no parameters";}

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

    A(A anda) { cout << "A object A parameter";}

    };

    class B : public A {

    public:

    B() { cout << "B no parameters";}

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

    B(int s) { cout << "B int parameter";}

    };

    int main () {

    A a2("Test");

    B b1(10);

    B b2(b1);

    return 0;

    }

    A. It prints: A no parametersA no parametersB string parameter
    B. It prints: A string parameterA no parametersB int parameterA object A parameter
    C. It prints: A no parametersB string parameter
    D. It prints: A no parametersA no parameters

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.