Question 1 of 25
Hints left: 3
Q1
What will be the output of the following C++ code? #include <iostream> using namespace std; template<typename T>class clsTemplate { public: T value; clsTemplate(T i) { this->value = i; } void test() { cout << value << endl; } }; class clsChild : public clsTemplate<char> { public: clsChild(): clsTemplate<char>( 0 ) { } clsChild(char c): clsTemplate<char>( c ) { } void test2() { test(); } }; int main() { clsTemplate <int> a( 42 ); clsChild b( 'A' ); a.test(); b.test(); return 0; }
Q2
What is the use of sum() function in Valarray?
Q3
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> tp1; tp1 = make_tuple(6, 'a', "Hello"); int x; string y; tie(x,ignore,y) = tp1; cout<<"x: "<<x<<"\ny: "<<y<<endl; return 0; }
Q4
What will be the output of the following C++ code? #include <iostream> #include <functional> #include <numeric> using namespace std; int myaccumulator (int x, int y) { return x - y; } int myproduct (int x, int y) { return x + y; } int main () { int a = 100; int series1[] = {10, 20, 30}; int series2[] = {1, 2, 3}; cout << inner_product(series1, series1 + 3, series2, a ,myaccumulator, myproduct); cout << endl; return 0; }
Q5
What type of algorithm is not available in creating our own STL style algorithms?
Q6
Which operator is used as not operator in bitset?
Q7
What are the design requirements for building a container from the sratch?
Q8
What is meant by exception specification?
Q9
What should be used to point to a static class member?
Q10
Which alternative can replace the throw statement?
Q11
What will the max function in the numeric limit will return for type float?
Q12
What will be the output of the following C++ code? #include<iostream> #include<any> using namespace std; int main() { float val = 5.5; any var(val); cout<<var<<endl; char c = 'a'; var.emplace<char>(c); cout<<var<<endl; return 0; }
Q13
Which of the following operator is used to capture all the external variable by reference?
Q14
What will be the output of the following C++ code? #include <iostream> #include <stack> using namespace std; int main () { stack<int> myints; cout << (int) myints.size(); for (int i = 0; i < 5; i++) myints.push(i); cout << (int) myints.size() << endl; return 0; }
Q15
What will happen if an exception that is thrown may cause a whole load of objects to go out of scope?
Q16
Which function is used to access the first element of an array class?
Q17
How the list differs from vectors?
Q18
Which is used to throw a exception?
Q19
How many tests are available in read and write operations?
Q20
What is the use of sort_heap() function in heap?
Q21
What will be the output of the following C++ code? #include <iostream> #include <set> using namespace std; int main () { set<int> myset; myset.insert(20); myset.insert(30); myset.insert(10); while (!myset.empty()) { cout << ' ' << *myset.begin(); myset.erase(myset.begin()); } cout << '\n'; return 0; }
Q22
Which of the following is correct about Valarray?
Q23
What will be the output of the following C++ code? #include<iostream> using namespace std; class Print { public: void operator()(int a){ cout<<a<<endl; } }; int main() { Print print; print(5); return 0; }
Q24
What will be the output of the following C++ code? #include <iostream> #include <array> using namespace std; int main(int argc, char const *argv[]) { array<int, 5> arr1 = {1,2,3,4,5}; array<int, 5> arr2 = {6,7,8,9,10}; arr1.swap(arr2); for(int i=0;i<5;i++) cout<<arr1[i]<<" "; cout<<endl; for(int i=0;i<5;i++) cout<<arr2[i]<<" "; cout<<endl; return 0; }
Q25
What will be the output of the following C++ code? #include <iostream> #include <utility> using namespace std; int main () { pair p(1,2); cout<<"Pair(first,second) = ("<<p.first<<","<<p.second<<")\n"; return 0; }