Free CPP-22-02 Mock Exam – Practice Online Confidently

Increase your chances of passing the C++ Institute CPP-22-02 exam questions on your first try. Practice with our free online CPP-22-02 exam mock test designed to help you prepare effectively and confidently.

Exam Code: CPP-22-02
Exam Questions: 230
CPP - C++ Certified Professional Programmer
Updated: 22 Sep, 2026
Question 1

What will happen when you attempt to compile and run the following code?
 #include <iostream>
 #include <string>
 using namespace std;
 template <class T>
 class A {
 T_v;
 public:
 A() {}
 A(T v): _v(v){}
 T getV() { return _v; }
 void add(T & a) { _v+=a; }
 };
 int main()
 {
 A<string>a("Hello"); string s(" world!");
 a.add(s);
 cout << a.getV() <<endl;
 return 0;
 }

Options :
Answer: A

Question 2

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

Options :
Answer: D

Question 3

What happens when you attempt to compile and run the following code?
 #include <iostream>
 #include <map>
 #include <string>
 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<int,string> m;
 for(int i=0; i<10; i++) {
 m.insert(pair<int,string>(second[i],first[i]));
 }
 if (m[11] == "eleven") {
 cout<<"eleven ";
 }
 for(multimap<int, string>::iterator i=m.begin();i!= m.end(); i++) {
 cout<<i?>second<<" ";
 }cout<<m.size();
 return 0;
 }

Options :
Answer: A

Question 4

What happens when you attempt to compile and run the following code?
 #include <iostream>
 #include <set>
 #include <list>
 using namespace std;
 int main(){
 int t[] ={ 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 };
 list<int>v(t, t+10);
 multiset<int> s1(v.begin(),v.end());
 if (s1.count(3) == 2) {
 s1.erase(3);
 }
 for(multiset<int>::iterator i=s1.begin();i!= s1.end(); i++) {
 cout<<*i<<" ";
 }
 return 0;
 } 

Options :
Answer: D

Question 5

What will happen when you attempt to compile and run the code below, assuming that you
 enter the following sequence: 1 2 3 end?

Options :
Answer: A

Viewing Page : 1 - 23
Practicing : 1 - 5 of 230 Questions

© Copyrights FreeMockExams 2026. All Rights Reserved

We use cookies to ensure that we give you the best experience on our website (FreeMockExams). If you continue without changing your settings, we'll assume that you are happy to receive all cookies on the FreeMockExams.