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

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

    #include

    #include

    using namespace std;

    class A {

    protected:

    int y;

    public:

    int x,z;

    A() : x(1), y(2), z(0) { z = x + y; }

    A(int a, int b) : x(a), y(b) { z = x + y;}

    void Print() { cout << z; }

    };

    class B : public A {

    public:

    int y;

    B() : A() {}

    B(int a, int b) : A(a,b) {}

    void Print() { cout << z; }

    };

    int main () {

    A b;

    b.Print();

    return 0;

    }

    A. It prints: 3

    B. It prints: 0

    C. It prints: 1

    D. It prints: 2

  • Question 82:

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

    #include

    #include

    using namespace std;

    float* sum(float a,float b);

    float* sum(float a,float b)

    {

    float *f = new float;

    *f = a+b;

    return f;

    }

    int main()

    {

    float a,b,*f;

    a = 1.5; b = 3.4;

    f = sum(a,b);

    cout<<*f;

    return 0;

    }

    A. It prints: 0

    B. It prints: 4.9

    C. It prints: 5

    D. It prints: 4

  • Question 83:

    What is the output of the program given below?

    #include

    using namespace std;

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

    {

    int i=10;

    {

    int i=0;

    cout<

    }

    {

    i=5;

    cout << i;

    }

    cout<

    return 0;

    }

    A. 1010

    B. 101010

    C. 055

    D. None of these

  • Question 84:

    Which of the structures is incorrect?

    1: struct s1{ int x; long int li; }; 2: struct s2{ float f; struct s2 *s; };

    3:

    struct s3{ float f; struct s3 s; };

    A.

    1

    B.

    2

    C.

    3

    D.

    2, 3

  • Question 85:

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

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

    #include

    using namespace std;

    int fun(int x) {

    return 2*x;

    }

    int main(){

    int i;

    i = fun(1) and fun(0);

    cout << i;

    return 0;

    }

    A. It prints: 0

    B. It prints: 1

    C. It prints: -1

    D. Compilation error

  • Question 87:

    What is the output of the program?

    #include

    #include

    using namespace std;

    class First

    {

    string name;

    public:

    First() {

    name = "Alan";

    }

    cout << name;

    }

    };

    int main()

    {

    First ob1,*ob2;

    ob2 = new First();

    ob1.Print();

    ob2?>Print();

    }

    A. Garbage value

    B. It prints: AlanAlan

    C. It prints: Alan

    D. It prints: Al

  • Question 88:

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

    #include

    using namespace std;

    int fun(int x);

    int main() {

    cout << fun(0);

    }

    int fun(int x) {

    if(x > 0)

    return fun(x-1);

    else

    return 100;

    }

    A. It prints: 0

    B. It prints: 10

    C. It prints: 100

    D. It prints: -1

  • Question 89:

    What will the variable "age" be in class B?

    class A {

    int x;

    protected:

    int y;

    public:

    int age;

    };

    class B : protected A {

    string name;

    public:

    void Print() {

    cout << name << age;

    }

    };

    A. public

    B. private

    C. protected

    D. None of these

  • Question 90:

    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.