Question 1 of 25
Hints left: 3
Q1
What is the validity of template parameters?
Q2
How many different ways are there to access an element of array classes at the ith position?
Q3
What are different operations are used in Pseudo-random number engines?
Q4
Which handler is used to handle all types of exception?
Q5
Which can be used to create a random number without duplication?
Q6
Which header file is used with input and output operations of C in C++?
Q7
What will be the output of the following C++ code? #include <iostream> #include <Valarray> using namespace std; int main() { Valarray<int> varr = { 1, 2, 3, 4, 5 }; for (int &x: varr) cout << x << " "; cout<<endl; varr = varr.shift(-3); for (int &x: varr) cout << x << " "; return 0; }
Q8
What will be the output of the following C++ code? #include <iostream> #include <limits> using namespace std; int main () { cout << boolalpha; cout << numeric_limits<int> :: has_infinity << '\n'; return 0; }
Q9
Pick out the correct answer.
Q10
What will be the output of 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); int *pos = v.data(); cout<<*(pos + 3); return 0; }
Q11
What is meant by template specialization?
Q12
What is the property of partial sort function provided by the STL algorithm?
Q13
What will be the output of the following C++ code? #include <iostream> #include <queue> using namespace std; int main () { priority_queue<int> mypq; mypq.push(30); mypq.push(100); mypq.push(25); mypq.push(40); while (!mypq.empty()) { cout << " " << mypq.top(); mypq.pop(); } cout << endl; return 0; }
Q14
What are the two advantage of function objects than the function call?
Q15
What will be the output of the following C++ code? #include <iostream> #include <vector> #include<iterator> using namespace std; int main () { vector<int> myvector; for (int i = 1; i <= 10; i++) myvector.push_back(i); myvector.erase (myvector.begin() + 6); myvector.erase (myvector.begin(), myvector.begin() + 4); for (unsigned i = 0; i < myvector.size(); ++i) cout << ' ' << myvector[i]; return 0; }
Q16
What will be the output of the following C++ code? #include <iostream> #include <vector> using namespace std; class Component { public: virtual void traverse() = 0; }; class Leaf: public Component { int value; public: Leaf(int val) { value = val; } void traverse() { cout << value << ' '; } }; class Composite: public Component { vector < Component * > children; public: void add(Component *ele) { children.push_back(ele); } void traverse() { for (int i = 0; i < children.size(); i++) children[i]->traverse(); } }; int main() { Composite containers[4]; for (int i = 0; i < 4; i++) for (int j = 0; j < 3; j++) containers[i].add(new Leaf(i *3+j)); for (int k = 1; k < 4; k++) containers[0].add(&(containers[k])); for (int p = 0; p < 4; p++) { containers[p].traverse(); } }
Q17
In what form does the STL provides heap?
Q18
What will be the output of the following C++ code? #include <iostream> #include <vector> #include <forward_list> using namespace std; int main() { forward_list<int> fl1 = {1,2,3,4,5}; for (int&c : fl1) cout << c << " "; cout<<endl; forward_list<int>::iterator ptr = fl1.begin(); fl1.erase_after(ptr); for (int&c : fl1) cout << c << " "; cout<<endl; return 0; }
Q19
Which of the following is correct way of copying the values of pair p1 into other pair p2?
Q20
Which of the following is true about exception handling in C++? i. There is a standard exception class in C++ similar to Exception class in Java. ii. All exceptions are unchecked in C++, i.e., the compiler does not checks if the exceptions are caught or not. iii. In C++, a function can specify the list of exceptions that it can throw using comma separated list like following. void fun(int a, char b) throw (Exception1, Exception2, ..)
Q21
What will be the output of the following C++ code? #include <iostream> using namespace std; int add(int a, int b); int main() { int i = 5, j = 6; cout << add(i, j) << endl; return 0; } int add(int a, int b ) { int sum = a + b; a = 7; return a + b; }
Q22
What is the use of reference member type in allocator?
Q23
What is the full form of vtable?
Q24
Which is the correct syntax of constructing a bitset?
Q25
To use external linkage we have to use which keyword?