CPP-22-02 Exam Details

  • Exam Code
    :CPP-22-02
  • Exam Name
    :CPP - C++ Certified Professional Programmer
  • Certification
    :C++ Institute Certifications
  • Vendor
    :C++ Institute
  • Total Questions
    :228 Q&As
  • Last Updated
    :

C++ Institute CPP-22-02 Online Questions & Answers

  • Question 1:

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

    #include

    #include

    #include

    using namespace std;

    template

    void print(T start, T end) {

    while (start != end) {

    std::cout << *start << " "; start++;

    }

    }

    int main()

    {

    int t1[] ={ 1, 7, 8, 4, 5 };

    list l1(t1, t1 + 5);

    int t2[] ={ 3, 2, 6, 9, 0 };

    deque d1(t2, t2 + 5);

    l1.sort();

    d1.sort();

    l1.merge(d1);

    print(l1.begin(), l1.end());

    print(d1.begin(), d2.end()); cout<

    return 0;

    }

    A. program outputs: 0 1 2 3 4 5 6 7 8 9 0 2 3 6 9
    B. program outputs: 0 1 2 3 4 5 6 7 8 9
    C. program outputs: 9 8 7 6 5 4 3 2 1 0
    D. compilation error

  • Question 2:

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

    #include

    #include

    #include

    #include

    #include

    using namespace std;

    struct display {

    void operator() (int i) {cout << " " << i;}

    };

    int main() {

    int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 };

    vector v1(t, t + 10);

    deque d1(t, t + 10);

    set s1(t, t + 10);

    for_each(v1.begin(), v1.end(), display); //Line I

    for_each(d1.begin(), d1.end(), *(new display())); // Line II

    for_each(s1.begin(), s1.end(), display()); // Line III

    return 0;

    }

    A. program outputs: 10 5 9 6 2 4 7 8 3 1 10 5 9 6 2 4 7 8 3 1 1 2 3 4 5 6 7 8 9 10
    B. program outputs: 10 5 9 6 2 4 7 8 3 1 10 5 9 6 2 4 7 8 3 1 10 5 9 6 2 4 7 8 3 1
    C. compilation error in line I
    D. compilation error in line II
    E. compilation error in line III

  • Question 3:

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

    #include

    #include

    #include

    using namespace std;

    int main () {

    int t[] = {1,2,3,4,5,1,2,3,4,5};

    vector v (t,t+10);

    vector::iterator it;

    int m1[] = {1, 3, 2};

    it = find_first_of (v.begin(), v.end(), m1, m1+3);

    cout << "First found at position: " << it?v.begin() << endl;

    return 0;

    }

    A. program outputs: First found at position: 5
    B. program outputs: First found at position: 0
    C. program outputs: First found at position: 6
    D. program outputs: First found at position: 1
    E. program outputs: First found at position: 10

  • Question 4:

    What happens when you attempt to compile and run the following code? Choose all possible answers.

    #include

    using namespace std;

    class C {

    public:

    int _c;

    C():_c(0){}

    C(int c) { _c = c;}

    C operator+=(C and b) {

    C tmp; tmp._c = _c+b._c;

    return tmp;

    } };

    ostream and operator<<(ostream and c, const C and v) {

    c<

    template

    class A {

    T_v;

    public:

    A() {}

    A(T v): _v(v){}

    T getV() { return _v; }

    void add(T and a) { _v+=a; }

    };

    int main()

    {

    A b(2);

    Aa (5);

    a.add(C());

    cout << a.getV() <

    return 0;

    }

    A. program will display:5
    B. program will not compile
    C. program will compile
    D. program will cause runtime exception

  • Question 5:

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

    #include

    #include

    #include

    using namespace std;

    class B { int val;

    public:

    B(int v):val(v){} B(){}

    int getV() const {return val;} };

    ostream and operator <<(ostream and out, const B and v) { out<

    templatestruct Out {

    ostream and out;

    Out(ostream and o): out(o){}

    void operator() (const T and val ) { out<

    int main() {

    int t[]={8, 10, 5, 1, 4, 6, 2, 7, 9, 3};

    deque d1(t, t+10);

    deque::iterator it = lower_bound(d1.begin(), d1.end(), 4);

    for_each(it, d1.end(), Out(cout));cout<

    return 0;

    }

    Program outputs:

    A. 8 10 5 1 4 6 2 7 9 3
    B. 4 5 6 7 8 9 10
    C. 1 2 3 4 5 6 7 8 9 10
    D. compilation error
    E. 1 2 3 4

  • Question 6:

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

    #include

    #include

    #include

    using namespace std;

    int main () {

    int t[] = {1,2,3,2,3,5,1,2,7,3,2,1,10, 4,4,5};

    vector v (t,t+15);

    int number = count(v.begin(), v.end(), 2);

    cout<< number<

    return 0;

    }

    Program outputs:

    A. 4
    B. 3
    C. 2
    E. compilation error

  • Question 7:

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

    #include

    #include

    #include

    using namespace std;

    template void print(T start, T end) {

    while (start != end) {

    std::cout << *start << " "; start++;

    }

    }

    int main(){

    vectorv;

    multiset s;

    for(int i=10; i>0; i??) {

    v.push_back(i); s.push_back(i);

    }

    print(v.begin(), v.end()); print(s.begin(), s.end());cout<

    return 0;

    }

    A. program outputs: 10 9 8 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 9 10
    B. program outputs: 10 9 8 7 6 5 4 3 2 1 10 9 8 7 6 5 4 3 2 1
    C. program outputs: 10 9 8 7 6 5 4 3 2 1 and unpredictable sequence of numbers range 1 to 10
    D. compilation error

  • Question 8:

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

    #include

    #include

    #include

    using namespace std;

    templatestruct Out {

    ostream and out;

    Out(ostream and o): out(o){}

    void operator()(const T and val ) {

    out<

    }

    };

    struct Sequence {

    int start;

    Sequence(int start):start(start){}

    int operator()() { return start++; } };

    int main() {

    vector v1(10);

    vector v2(10);

    generate(v1.begin(), v1.end(), Sequence(1));

    random(v1.begin(),v1.end());

    for_each(v1.begin(), v1.end(), Out(cout) );cout<

    return 0;

    }

    Program outputs:

    A. 1 2 3 4 5 6 7 8 9 10
    B. 10 9 8 7 6 5 4 3 2 1
    C. 8 2 4 9 5 7 10 6 1 3
    D. compilation error

  • Question 9:

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

    #include

    #include

    #include

    using namespace std;

    template void print(T start, T end) {

    while (start != end) {

    std::cout << *start << " "; start++;

    }

    }

    int main() {

    string t1[] ={ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};

    list l1(t1, t1 + 10);

    list l2(l1);

    l2.reverse(); l1.splice(l1.end(),l2);

    l1.unique();

    print(l1.begin(), l1.end()); cout<

    return 0;

    }

    A. compilation error
    B. program outputs: 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1
    C. program outputs: 1 2 3 4 5 6 7 8 9 10 10 9 8 7 6 5 4 3 2 1
    D. program outputs: 1 2 3 4 5 6 7 8 9 10

  • Question 10:

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

    #include

    #include

    #include

    #include

    using namespace std;

    class B { int val;

    public:

    B(int v=0):val(v){}

    int getV() const {return val;}

    operator int () const { return val;} };

    ostream and operator <<(ostream and out, const B and v) { out<

    templatestruct Out {

    ostream and out;

    Out(ostream and o): out(o){}

    void operator() (const T and val ) { out<

    int main() {

    B t[]={3,2,4,1,5,6,10,8,7,9};

    vector v1(t, t+10);

    transform(v1.begin(), v1.end(), v1.begin(), bind2nd(plus(), 1));

    for_each(v1.rbegin(), v1.rend(), Out(cout));cout<

    }

    Program outputs:

    A. 3 2 4 1 5 6 10 8 7 9
    B. 4 3 5 2 6 7 11 9 8 10
    C. 9 7 8 10 6 5 1 4 2 3
    D. 10 8 9 11 7 6 2 5 3 4
    E. compilation error

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