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

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

    #include

    #include

    using namespace std;

    class complex{

    double re, im;

    public:

    complex() : re(1),im(0.3) {}

    complex(double n) { re=n,im=n;};

    complex(int m,int n) { re=m,im=n;}

    complex operator+(complex andt);

    void Print() { cout << re << " " << im; }

    };

    complex complex::operator+ (complex andt){

    complex temp;

    temp.re = this?>re + t.re;

    temp.im = this?>im + t.im;

    return temp;

    }

    int main(){

    complex c1(1),c2(2),c3;

    c3 = c1 + c2;

    c3.Print();

    }

    A. It prints: 1 1.5
    B. It prints: 2 1.5
    C. It prints: 3 3
    D. It prints: 0 0

  • Question 142:

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

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

    #include

    using namespace std;

    class A {

    public:

    virtual void Print()=0;

    };

    class B:public A {

    public:

    virtual void Print() { cout<< "B"; }

    };

    class C:public A {

    public:

    virtual void Print() { cout<< "C"; }

    };

    int main()

    {

    B ob2;

    C ob3;

    A *obj;

    obj = andob2;

    obj?>Print();

    obj = andob3;

    obj?>Print();

    }

    A. It prints: BC
    B. It prints: CB
    C. It prints: CC
    D. It prints: BB

  • Question 144:

    What is the output of the program if characters 'h', 'e', 'l', 'l' , 'o' and enter are supplied as input?

    #include

    #include

    using namespace std;

    void f();

    int main()

    {

    f();

    return 0;

    }

    void f()

    {

    char c;

    c = cin.get();

    cout << c;

    if(c != '\n')

    f();

    }

    A. It prints: hello
    B. It prints: olleh
    C. It prints: h
    D. It prints: o

  • Question 145:

    The following declaration: int i = 0b10;

    A. is invalid
    B. sets variable i with an integer value equal to 10
    C. sets variable i with an integer value equal to 2 (10 binary)
    D. sets variable i with an integer value equal to 8 (10 octal)

  • Question 146:

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

    #include

    using namespace std;

    int main()

    {

    int x=0;

    int *ptr;

    ptr = andx;

    cout<

    return 0;

    }

    A. It prints: 0 0
    B. It prints address of ptr
    C. It prints: 1
    D. It prints: 2

  • Question 147:

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

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

    #include

    using namespace std;

    class A

    {

    public:

    void Print(){ cout<<"A";}

    };

    class B:public A

    {

    public:

    virtual void Print(){ cout<< "B";}

    };

    int main()

    {

    A *obj;

    A ob1;

    obj = andob1;

    obj?>Print();

    B ob2;

    obj = andob2;

    obj?>Print();

    }

    A. It prints: AB
    B. It prints: AA
    C. It prints: BA
    D. It prints: BB

  • Question 149:

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

    #include

    using namespace std;

    int main()

    {

    int x=20;

    int *ptr;

    ptr = andx;

    cout<<*ptr;

    return 0;

    }

    A. It prints: 20
    B. It prints: 0
    C. It prints address of ptr
    D. It prints: 2

  • Question 150:

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

    #include

    using namespace std;

    int x=5;

    static int y;

    int i=0;

    void static myFunction()

    {

    y=x++ + ++i;

    }

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

    {

    x++;

    myFunction();

    cout<

    }

    A. Compilation fails
    B. It prints: 5 5 0
    C. It prints: 7 7 1
    D. It prints: 6 5 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.