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

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

    #include

    using namespace std;

    int main(){

    int i = 1;

    if (i==1) {

    cout << i;

    } else {

    cout << i-1;

    }

    return 0;

    }

    A. It prints: 0

    B. It prints: 1

    C. It prints: -1

    D. It prints: 2

  • Question 32:

    Which of the following statements are correct?

    A. A function can be defined inside another function

    B. A function may have any number of return statements each returning different values.

    C. A function can return floating point value

    D. In a function two return statements should never occur.

  • Question 33:

    What will the variable "y" 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 34:

    What is the output of the program?

    #include

    #include

    using namespace std;

    int main()

    {

    string s1="Hello";

    string s2="World";

    s1+=s2;

    cout << s1;

    return( 0 );

    }

    A. It prints: HelloWorld

    B. It prints: Hello

    C. It prints: World

    D. It prints: HelWorld

  • Question 35:

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

    #include

    using namespace std;

    int main()

    {

    const int x=20;

    const int *ptr;

    ptr = andx;

    *ptr = 10;

    cout<<*ptr;

    return 0;

    }

    A. It prints: 20

    B. It prints: 10

    C. Compilation error at line 8

    D. It prints address of ptr

  • Question 36:

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

    #include

    #include

    using namespace std;

    class A {

    public:

    A() { cout << "A0 ";}

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

    };

    class B : public A {

    public:

    B() { cout << "B0 ";}

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

    };

    class C : private B {

    public:

    C() { cout << "C0 ";}

    C(string s) { cout << "C1 ";}

    };

    int main () {

    B b1;

    C c1;

    return 0;

    }

    A. It prints: A0 B0 A0 B1 A0 C0 A0 C1

    B. It prints: B0 B1 C0 C1

    C. It prints: A0 B0 A0 B0 C0

    D. It prints: B0 B1

  • Question 37:

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

    #include

    using namespace std;

    int getValue();

    int main()

    {

    const int x = getValue();

    cout<

    return 0;

    }

    int getValue()

    {

    return 5;

    }

    A. It will print 0

    B. The code will not compile.

    C. It will print 5

    D. It will print garbage value

  • Question 38:

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

    class A {

    int x;

    protected:

    int y;

    public:

    int age;

    A () { age=5; };

    };

    class B : public A {

    string name;

    public:

    B () { name="Bob"; };

    void Print() {

    cout << name << age;

    }

    };

    A. public

    B. private

    C. protected

    D. None of these

  • Question 39:

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

    #include

    using namespace std;

    int s(int n);

    int main()

    {

    int a;

    a = 3;

    cout << s(a);

    return 0;

    }

    int s(int n)

    {

    if(n == 0) return 1;

    return s(n?1)*n;

    }

    A. It prints: 4

    B. It prints: 6

    C. It prints: 3

    D. It prints: 0

  • Question 40:

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

    #include

    using namespace std;

    int fun(int x) {

    return x<<2;

    }

    int main(){

    int i;

    i = fun(1) / 2;

    cout << i;

    return 0;

    }

    A. It prints: 0

    B. It prints: 1

    C. It prints: 2

    D. It prints: 4

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.