Question 1 of 25
Hints left: 3
Q1
What will be the output of the following C++ code? #include <iostream> #include <typeinfo> using namespace std; class Polymorphic {virtual void Member(){}}; int main () { try { Polymorphic * pb = 0; typeid(*pb); } catch (exception& e) { cerr << "exception caught: " << e.what() << endl; } return 0; }
Q2
What does a default header file contain?
Q3
What will be the output of the following C++ code? #include <iostream> #include <algorithm> using namespace std; int main () { cout << "max(1, 2) == " << max(1, 2) << '\n'; cout << "max('a', 'z') == " << max('a', 'z') << '\n'; return 0; }
Q4
Which container can have the same keys?
Q5
What is the syntax of declaraing a forward_list?
Q6
In how many ways we can handle errors in any class?
Q7
What will be the capacity of vector at the end in the following C++ code? #include <iostream> #include <vector> using namespace std; int main() { vector<int> v; for (int i = 1; i <= 5; i++) v.push_back(i); v.reserve(50); cout<<v.capacity(); return 0; }
Q8
What is the use of no linkage?
Q9
Which header file is required to use heap in your program?
Q10
What will be the output of the following C++ code? #include <iostream> #include <bitset> using namespace std; int main() { bitset<8> b1(string("15")); cout<<b1; }
Q11
Which of the following header file does not exist?
Q12
What will be the output of the following C++ code in the text file? #include <stdio.h> int main () { FILE * pFile; char c; pFile = fopen("sample.txt", "wt"); for (c = 'A'; c <= 'E'; c++) { putc (c, pFile); } fclose (pFile); return 0; }
Q13
Which member function is used to determine whether the stream object is currently associated with a file?
Q14
Which of the following type does the container should define?
Q15
Which function is used to swap two vectors?
Q16
What happens when only one argument is supplied to flip() function?
Q17
How to handle the exception in constructor?
Q18
What will be the output of the following C++ code? #include<iostream> #include <string> using namespace std; template <class T> class Print { public: int operator()(T a){ cout<<a<<endl; } }; int main() { Print<string> str; Print<int> integer; int a = 100; string s = "Hello World"; str(s); integer(a); return 0; }
Q19
Which of the following is correct about none() function in bitset?
Q20
What will be the output of the following C++ code? #include <iostream> #include <string> #include <tuple> using namespace std; int main() { tuple <int, char, string> tp; tp = make_tuple("Hello", 4, 'c'); return 0; }
Q21
What will be the output of the following C++ code? #include <iostream> #include <bitset> using namespace std; int main() { bitset<8> b1(95); bitset<8> b2 = b1 >> 3; cout<<b1<<endl<<b2; }
Q22
What will be the output of the following C++ code? #include <iostream> #include <deque> using namespace std; int main () { deque<int> mydeque; int sum (0); mydeque.push_back ( 10 ); mydeque.push_back ( 20 ); mydeque.push_back ( 30 ); while (!mydeque.empty()) { sum += mydeque.back(); mydeque.pop_back(); } cout << sum << '\n'; return 0; }
Q23
What will be the output of the following C++ code? #include <iostream> #include <deque> using namespace std; int main () { unsigned int i; deque<int> a (3,100); deque<int> b (5,200); a.swap(b); cout << "a contains:"; for (deque<int>::iterator it = a.begin(); it != a.end(); ++it) cout << ' ' << *it; cout << "b contains:"; for (deque<int>::iterator it = b.begin(); it != b.end(); ++it) cout << ' ' << *it; return 0; }
Q24
Which is present in the basic interface of the allocator interface?
Q25
Which header file is required to use pair container in your program?