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
    :Jul 15, 2026

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

  • Question 11:

    Which keywords can be used to define template type parameters? Choose all possible answers:

    A. class
    B. typedef
    C. typename
    D. static
    E. volatile

  • Question 12:

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

    #include

    #include

    using namespace std;

    bool mycomparison (int first, int second){return first>second;}

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

    list l2(t2, t2 + 5);

    l1.sort(mycomparison);

    l2.sort(mycomparison);

    l1.merge(l2,mycomparison);

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

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

    return 0;

    }

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

  • Question 13:

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

    #include

    #include

    #include

    #include

    #include

    using namespace std;

    int main()

    {

    deque mydeck;list mylist; vector myvector;

    queue first; queue second(mydeck);

    queue third(second); queue > fourth(mylist);

    fourth.push(10);fourth.push(11);fourth.push(12);

    queue > fifth(myvector);

    fifth.push(10);fifth.push(11);fifth.push(12); // Line I

    while(!fifth.empty())

    {

    cout<

    fifth.pop(); // Line III

    }

    while (!fourth.empty())

    {

    cout << fourth.front() << " ";

    fourth.pop(); // Line IV

    }

    return 0;

    }

    A. program outputs: 10 11 12 10 11 12
    B. compilation error in line I
    C. compilation error in line II
    D. compilation error in line III
    E. compilation error in line IV

  • Question 14:

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

    #include

    #include

    #include

    using namespace std;

    int main(){

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

    vectorv(t, t+10);

    set s1(v.begin(),v.end());

    s1.insert(v.begin(),v.end());

    bool found = s1.find(7);

    if (found){

    cout<<"Element found!\n";

    }else {

    cout<<"Element not found!\n";

    }

    return 0;

    }

    A. program will display "Element found!"
    B. program will display "Element not found!\n"
    C. code will not compile
    D. changing type of variable found to int will make this code compile

  • Question 15:

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

    #include

    #include

    #include

    using namespace std;

    bool compare(int a, int b) { return a == b; }

    int main () {

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

    vector v (t,t+10);

    vector::iterator it = v.begin();

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

    while ( (it = find_first_of (it, v.end(), m1, m1+3)) != v.end()) {

    cout<

    }

    cout<< endl;

    return 0;

    }

    A. program outputs: 0 1 2 5 6 7
    B. program outputs: 0 5
    C. program outputs: 0 0
    D. compilation error
    E. program will run forever

  • Question 16:

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

    #include

    #include

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

    templatestruct Out {

    ostream and out;

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

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

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

    fstream f("test.out", ios::trunc|ios::out);

    list l(t, t+10);

    for_each(l.begin(), l.end(), Out(f));

    f.close();

    f.open("test.out");

    for( ; f.good() ; ) {

    B i;

    f>>i;

    cout<

    }

    f.close();

    return 0;

    }

    A. file test.out will be opened writing
    B. file test.out will be truncated
    C. file test.out will be opened for reading
    D. compilation error
    E. program will display sequence 1 2 3 4 5 6 7 8 9 10

  • Question 17:

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

    #include

    #include

    #include

    using namespace std;

    int main(){

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

    string first[] = {"three", "four", "two", "one", "six","five", "seven", "nine","eight"," ten"};

    multimap m;

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

    m.insert(pair(second[i],first[i]));

    }

    if (m[11] == "eleven") {

    cout<<"eleven ";

    }

    for(multimap::iterator i=m.begin();i!= m.end(); i++) {

    cout<second<<" ";

    }

    cout<

    return 0;

    }

    A. program outputs: one two three four five six seven eight nine ten 11
    B. program outputs: one two three four five six seven eight nine ten 10
    C. program outputs: one two three four five six seven eight nine ten 10
    D. program outputs: eleven one two three four five six seven eight nine ten 10
    E. compilation error

  • Question 18:

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

    #include

    using namespace std;

    template

    class A {

    T_v;

    public:

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

    T getV() { return _v; }

    };

    int main()

    {

    A a(1);

    cout << a.getV() <

    return 0;

    }

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

  • Question 19:

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

    #include

    #include

    #include

    #include

    using namespace std;

    templatestruct Out {

    ostream and out;

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

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

    int main() {

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

    int t2[]={6,10,8,7,9};

    vector v1(5);

    transform(t1,t1+5,t2,v1.rbegin(), plus());

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

    return 0;

    }

    Program outputs:

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

  • Question 20:

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

    #include

    using namespace std;

    class B {};

    template

    class A {

    T_v;

    public:

    A() {}

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

    T getV() { return _v; }

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

    };

    int main()

    {

    A a(1);

    Ab;

    a.add(10);

    cout << a.getV() <

    return 0;

    }

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

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.