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

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

    #include

    using namespace std;

    class complex{

    double re;

    double im;

    public:

    complex() : re(0),im(0) {}

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

    complex(double x,double y) { re=x,im=y;}

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

    };

    int main(){

    complex c1;

    double i=2;

    c1 = i;

    c1.print();

    return 0; }

    A. It prints: 0 0

    B. It prints: 1 1

    C. It prints: 2 0

    D. It prints: 2 2

  • Question 62:

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

    #include

    using namespace std;

    class A {

    public:

    int x;

    };

    class B : public A {

    public:

    B() { x=1;}

    B(int x) {this?>x = x;}

    };

    int main () {

    B c1;

    B c2(10);

    cout << c1.x;

    cout << c2.x;

    return 0;

    }

    A. It prints: 010

    B. It prints: 110

    C. It prints: 00

    D. It prints: 1

  • Question 63:

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

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

    class A {

    int x;

    protected:

    int y;

    public:

    int age;

    };

    class B : private A {

    string name;

    public:

    void Print() {

    cout << name << age;

    }

    };

    A. public

    B. private

    C. protected

    D. None of these

  • Question 65:

    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:

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

    };

    int main()

    {

    First FirstObject;

    FirstObject.Print();

    Second SecondObject;

    SecondObject.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 66:

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

    What will be the output of the program?

    #include

    using namespace std;

    int fun(int);

    int main()

    {

    cout << fun(5);

    return 0;

    }

    int fun(int i)

    {

    return i*i;

    }

    A. 25

    B. 5

    C. 0

    D. 1

  • Question 68:

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

    #include

    class complex{

    double re;

    double im;

    public:

    complex() : re(0),im(0) {}

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

    complex(double x,double y) { re=x,im=y;}

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

    };

    int main(){

    complex c1(1,2);

    c1.print();

    return 0;

    }

    A. It prints: 1 0

    B. It prints: 1 1

    C. It prints: 1 2

    D. Compilation error

  • Question 69:

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

    #include

    using namespace std;

    class Test {

    float i,j;

    };

    class Add {

    public:

    int x,y;

    Add (int a=3, int b=3) { x=a; y=b; }

    int result() { return x+y;}

    };

    int main () {

    Test test;

    Add * padd;

    padd = andtest;

    cout << padd?>result();

    return 0;

    }

    A. It prints: 6

    B. It prints: 9

    C. Compilation error

    D. It prints: 33

  • Question 70:

    What is the output of the program?

    #include

    #include

    using namespace std;

    int main()

    {

    string s1[]= {"Hello" , "World" };

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

    cout << s1[i];

    }

    return( 0 );

    }

    A. It prints: HelloWorld

    B. It prints: Hello

    C. It prints: WorldHello

    D. It prints: World

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.