Exam Details

  • Exam Code
    :CPA
  • Exam Name
    :C++ Certified Associate Programmer
  • Certification
    :C++ Certified Professional Programmer
  • Vendor
    :C++ Institute
  • Total Questions
    :220 Q&As
  • Last Updated
    :May 11, 2024

C++ Institute C++ Certified Professional Programmer CPA Questions & Answers

  • Question 41:

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

    #include

    using namespace std;

    int main()

    {

    int i=2;

    switch(i)

    {

    case 1:

    cout<<"Hello";

    break;

    case 2:

    cout<<"world";

    break;

    case 3:

    printf("End");

    break;

    }

    return 0;

    }

    A. It prints: Hello

    B. It prints: world

    C. It prints: End

    D. It prints: E

  • Question 42:

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

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

    #include

    #include

    using namespace std;

    class Base

    {

    string s;

    public:

    Base() { s="Sample text";}

    Base(string s) { this?>s=s; }

    void Print() { cout << s; }

    };

    int main()

    {

    Base *o = new Base();

    o?>Print();

    }

    A. It prints: Sample text

    B. It prints: Sample

    C. It prints: text

    D. None of these

  • Question 44:

    What is the output of the program?

    #include

    using namespace std;

    class BaseC

    {

    int i;

    public:

    BaseC() { i=?1;}

    BaseC(int i) { i=i; }

    void seti(int a) { i = a; };

    void Print() { cout << i; }

    };

    int main()

    {

    BaseC *o = new BaseC();

    o?>seti(10);

    o?>Print();

    }

    A. It prints: 10

    B. It prints: ?1

    C. It prints: 0

    D. Compilation error

  • Question 45:

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

    #include #include

    using namespace std;

    int fun(int);

    int main()

    {

    int *x = new int;

    *x=10;

    cout << fun(*x);

    return 0;

    }

    int fun(int i)

    {

    return i*i;

    }

    A. It will print: 100

    B. It will print: 101

    C. It will print: 10

    D. It will print: 1

  • Question 46:

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

    #include

    using namespace std;

    struct Person {

    string name;

    int age;

    };

    class First

    {

    Person *person;

    public:

    First() {person = new Person;

    person?>name = "John";

    person?>age = 30;

    }

    void Print(){

    cout<name << " "<< person?>age;

    }

    };

    int main()

    {

    First t[2];

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

    t[i].Print();

    }

    A. It prints: 30

    B. It prints: John

    C. It prints: John 31

    D. It prints: John 30John 30

  • Question 47:

    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(0.5) || fun(0);

    cout << i;

    return 0;

    }

    A. It prints: 0

    B. It prints: 1

    C. It prints: -1

    D. Compilation error

  • Question 48:

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

    #include

    #include

    using namespace std;

    class A {

    public:

    int age;

    A () { age=5; };

    };

    class B : private A { string name;

    public:

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

    void Print() {

    cout << name << age;

    }

    };

    int main () {

    B b,*ob;

    ob = andb;

    ob?>age = 10;

    ob?>Print();

    return 0;

    }

    A. It prints: Bob55

    B. It prints: Bob1

    C. It prints: 10

    D. Compilation error

  • Question 49:

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

    };

    int main()

    {

    B ob2;

    A *obj;

    obj = andob2;

    obj?>Print();

    }

    A. It prints: B

    B. It prints: A

    C. It prints: AB

    D. It prints: BA

  • Question 50:

    Which of the following is a correct way to define the function fun() in the program below?

    #include

    #include

    #include

    using namespace std;

    int main()

    {

    int a[2][2];

    fun(a);

    return 0;

    }

    A. void fun(int *p[2]) {}

    B. void fun(int *p[2][2]) {}

    C. void fun(int *p[][2]) {}

    D. void fun(int p[][2]) {}

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 exam preparations and C++ Institute certification application, do not hesitate to visit our Vcedump.com to find your solutions here.