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

    Point out an error in the program.

    #include

    using namespace std;

    int main()

    {

    const int x=1;

    int const *y=andx;

    cout<<*y;

    return 0;

    }

    A. No error

    B. Error: unknown pointer conversion

    C. cannot convert from 'const int *' to 'int *const'

    D. Compilation error

  • Question 22:

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

    #include

    using namespace std;

    int op(int x, int y)

    {

    return x?y;

    }

    int op(int x, float y)

    {

    return x+y;

    }

    int main()

    {

    int i=1, j=2, k, l;

    float f=0.23;

    k = op(i, j);

    l = op(j, f);

    cout<< k << "," << l;

    return 0;

    }

    A. It prints: ?1,?1

    B. It prints: ?1,3

    C. It prints: ?1,2

    D. Compilation fails

  • Question 23:

    What is the output of the program if character 4 is supplied as input?

    #include

    using namespace std;

    int main () {

    int c;

    cin >> c;

    {

    switch (c)

    {

    case 1:

    throw 20;

    case 2:

    throw 5.2f;

    case 3:

    throw 'a';

    default:

    cout<<"No exception";

    }

    }

    catch (int e)

    { cout << "int exception. Exception Nr. " << e; }

    catch (float e)

    { cout << "float exception. Exception Nr. " << e; }

    catch (...)

    { cout << "An exception occurred."; }

    return 0;

    }

    A. It prints: float exception. Exception Nr.

    B. It prints: int exception. Exception Nr.

    C. It prints: An exception occurred

    D. It prints: No exception

  • Question 24:

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

    #include

    using namespace std;

    int main(){

    int *i;

    i = new int;

    *i = 1.0 / 2 * 2 / 1 * 2 / 4 * 4;

    cout << *i;

    return 0;

    }

    A. It prints: 0

    B. It prints: 1

    C. It prints: 2

    D. It prints: 0.5

  • Question 25:

    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";} };

    int main () {

    A a2("Test");

    B b1("Alan");

    B b2(b1);

    return 0;

    }

    A. It prints: A no parametersA no parametersB string parameter

    B. It prints: A string parameterA no parametersB string parameterA object A parameter

    C. It prints: A no parametersB string parameter

    D. It prints: A no parametersA no parameters

  • Question 26:

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

    #include

    using namespace std;

    void fun(int andi);

    int main()

    {

    int i=2;

    fun(i);

    cout<

    return 0;

    }

    void fun(int andi)

    {

    i+=2;

    }

    A. It prints: 2

    B. It prints: 0

    C. It prints: 4

    D. It prints: 16

  • Question 27:

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

    What is the output of the program?

    #include

    #include

    using namespace std;

    int main()

    {

    string s1="Wo";

    string s2;

    s2 = s1;

    string s3;

    s3 = s2.append("rldHello");

    cout << s3;

    return( 0 );

    }

    A. It prints: WorldHello

    B. It prints: HelloWo

    C. It prints: World

    D. It prints: Hello

  • Question 29:

    Which of the following can be checked in a switch?case statement?

    A. char

    B. int

    C. enum

    D. double

  • Question 30:

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

    using namespace std;

    int op(int x, int y);

    int main()

    {

    float *pf;

    float f=0.9;

    pf=andf;

    cout << op(1, *pf);

    return 0;

    }

    int op(int x, int y)

    {

    return x*y;

    }

    A. It prints: 0

    B. It prints: 0.5

    C. It prints: 1

    D. It prints: ?1

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.