Skip to main content

Standard Template Library _Stl_ In C Plus Plus — Part 2 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Standard Template Library _Stl_ In C Plus Plus — Part 2 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.

Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40

Verified Practice Questions

Interactive test mode with detailed academic worked solutions

Live Progress | 0/40 answered
✓ 0 correct ✗ 0 wrong 0% score
Question 1 of 40
★ FPSC ★ PPSC

Which algorithm in C++ STL is used to shuffle the elements in a range randomly?

Question 2 of 40
★ FPSC ★ PPSC

What is the purpose of the 'std::forward_list' container in C++ STL?

Question 3 of 40
★ FPSC ★ PPSC

Which algorithm in C++ STL is used to sort a range of elements using quicksort?

Question 4 of 40
★ FPSC ★ PPSC

What is the purpose of the 'std::array' container in C++ STL?

Question 5 of 40
★ FPSC ★ PPSC

Which algorithm in C++ STL is used to compute the sum of elements in a range?

Question 6 of 40
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <stdio.h> #include <math.h> int main () { printf ("%lf\n", fmod (5.3, 2) ); printf ("%lf\n", fmod (18.5, 4.2) ); return 0; }

Question 7 of 40
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <typeinfo> #include <iostream> using namespace std; class shape { public: virtual void myvirtualfunc() const {} }; class mytriangle: public shape { public: virtual void myvirtualfunc() const { }; }; int main() { shape shape_instance; shape &ref_shape = shape_instance; try { mytriangle &ref_mytriangle = dynamic_cast (ref_shape); } catch (bad_cast) { cout << "Caught: bad_cast exception\n"; } return 0; }

Question 8 of 40
★ FPSC ★ PPSC

Which is best for coding the standard library for c++?

Question 9 of 40
★ FPSC ★ PPSC

Where are standard exception classes grouped?

Question 10 of 40
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> #include <algorithm> #include <vector> using namespace std; int main () { vector<int> myvector; for (int i = 1; i < 6; ++i) myvector.push_back(i); reverse(myvector.begin(), myvector.end()); for (vector<int> :: iterator it = myvector.begin(); it != myvector.end(); ++it) cout << ' ' << *it; return 0; }

Question 11 of 40
★ FPSC ★ PPSC

How many parameters are used in frexp function?

Question 12 of 40
★ FPSC ★ PPSC

Pick out parameter for rehash method in unordered_set in c++?

Question 13 of 40
★ FPSC ★ PPSC

What are Container Adaptors?

Question 14 of 40
★ FPSC ★ PPSC

What are Unordered Associative Containers?

Question 15 of 40
★ FPSC ★ PPSC

How does the limits.h header file can be represented in C++?

Question 16 of 40
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> #include <vector> using namespace std; int main() { vector<int> v; v.assign( 10, 42 ); for (int i = 0; i < v.size(); i++) { cout << v[i] << " "; } }

Question 17 of 40
★ FPSC ★ PPSC

Pick out the wrong header file.

Question 18 of 40
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <stdio.h> #include <stdlib.h> int main () { char s[] = "365.24 29.53"; char* p; double d1, d2; d1 = strtod (s, &p); d2 = strtod (p, NULL); printf ("%.2f\n", d1/d2); return 0; }

Question 19 of 40
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> #include <list> #include <queue> using namespace std; int main() { queue<char> q; q.push('a'); q.push('b'); q.push('c'); cout << q.front(); q.pop(); cout << q.front(); q.pop(); cout << q.front(); q.pop(); }

Question 20 of 40
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <list> #include <string> #include <iostream> using namespace std ; typedef list<string> LISTSTR; int main() { LISTSTR :: iterator i; LISTSTR test; test.insert(test.end(), "one"); test.insert(test.end(), "two"); LISTSTR test2(test); LISTSTR test3(3, "three"); LISTSTR test4(++test3.begin(), test3.end()); cout << "test:"; for (i = test.begin(); i != test.end(); ++i) cout << " " << *i << endl; cout << "test:"; for (i = test2.begin(); i != test2.end(); ++i) cout << " " << *i << endl; cout << "test:"; for (i = test3.begin(); i != test3.end(); ++i) cout << " " << *i << endl; cout << "test:"; for (i = test4.begin(); i != test4.end(); ++i) cout << " " << *i << endl; }

Question 21 of 40
★ FPSC ★ PPSC

Which header file is used for Iterators?

Question 22 of 40
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> #include <exception> using namespace std; class myexc: public exception { virtual const char* what() const throw() { return "My exception"; } } myex; int main () { try { throw myex; } catch (exception& e) { cout << e.what() << endl; } return 0; }

Question 23 of 40
★ FPSC ★ PPSC

What is the use of make_heap in the heap operation?

Question 24 of 40
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <stdio.h> #include <math.h> int main () { printf ("The value of -3.1416 is %lf\n", fabs (-3.1416)); return 0; }

Question 25 of 40
★ FPSC ★ PPSC

What are the predefined exceptions in c++?

Question 26 of 40
★ FPSC ★ PPSC

Pick out the correct library in the following choices.

Question 27 of 40
★ FPSC ★ PPSC

In how many categories, containers are divided?

Question 28 of 40
★ FPSC ★ PPSC

Which header file is used to declare the standard exception?

Question 29 of 40
★ FPSC ★ PPSC

Pick out the wrong header file about strings.

Question 30 of 40
★ FPSC ★ PPSC

What is the type of the first item in the heap?

Question 31 of 40
★ FPSC ★ PPSC

How many components STL has?

Question 32 of 40
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> #include <exception> using namespace std; int main () { try { int* myarray= new int[1000]; cout << "Allocated"; } catch (exception& e) { cout << "Standard exception: " << e.what() << endl; } return 0; }

Question 33 of 40
★ FPSC ★ PPSC

What is meant by standard c++ library?

Question 34 of 40
★ FPSC ★ PPSC

How many Container Adaptors are provided by C++?

Question 35 of 40
★ FPSC ★ PPSC

Which of the following mathematical function is overloaded in <complex> and <valarray>?

Question 36 of 40
★ FPSC ★ PPSC

Pick out the correct syntax of the header file that can be used with C++.

Question 37 of 40
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <stdio.h> #include <stdlib.h> int compareints (const void * a, const void * b) { return ( *(int*)a - *(int*)b ); } int values[] = { 50, 20, 60, 40, 10, 30 }; int main () { int * p; int key = 40; qsort(values, 6, sizeof (int), compareints); p = (int*) bsearch (&key, values, 6, sizeof (int), compareints); if (p != NULL) printf ("%d\n",*p); return 0; }

Question 38 of 40
★ FPSC ★ PPSC

With which does the trigonometric functions work with angles in c++?

Question 39 of 40
★ FPSC ★ PPSC

What are the Associative Containers?

Question 40 of 40
★ FPSC ★ PPSC

How many types of Iterators are provided by C++?

✓ Link copied to clipboard
Continue Your Practice

Advance Html — Part 1

Master the next curriculum module with 40 exam-standard MCQs.

Next Practice Set →

💡 Examiner's Advisory for Programming & Software Development

In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.

More Modules in Programming & Software Development

View All →
📚

Study Guides

Topic summaries and syllabus breakdown

Explore Guides →
🎯

Complete Library

Search through 78,000+ verified MCQs

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →