Question 1 of 25
Hints left: 3
Q2
Which of the following relationships is uni-directional?
Q3
In how many different ways any-container can be constructed?
Q4
Which is used to create a pure virtual function?
Q5
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; tuple <int, char, string> tp2; tp1 = make_tuple(6, 'a', "Hello"); tp2 = make_tuple(9, 'z', "World"); cout<<"("<<get<0>(tp1)<<", "<<get<1>(tp1)<<", "<<get<2>(tp1)<<")"<<endl; cout<<"("<<get<0>(tp2)<<", "<<get<1>(tp2)<<", "<<get<2>(tp2)<<")"<<endl; tp1.swap(tp2); cout<<"("<<get<0>(tp1)<<", "<<get<1>(tp1)<<", "<<get<2>(tp1)<<")"<<endl; cout<<"("<<get<0>(tp2)<<", "<<get<1>(tp2)<<", "<<get<2>(tp2)<<")"<<endl; return 0; }
-
A
-
B
-
C
-
D
Q6
What are the tuples in C++?
Q7
Which of the following function is used to insert an element at the end of a vector?
Q8
What will be the output of the following C++ code? #include <iostream> #include <vector> #include <algorithm> using namespace std; void show(const vector<int>& vi) { for (size_t i = 0; i < vi.size(); ++i) cout << vi[i]; cout << endl; } int main() { vector<int> vi; vi.push_back(3); vi.push_back(5); vi.push_back(5); sort(vi.begin(), vi.end()); show(vi); while(next_permutation(vi.begin(), vi.end())) show(vi); return 0; }
Q9
Identify the correct statement about throw(type).
Q10
What type of access does deque and vector provide?
Q11
What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int a = 10; if (a < 15) { time: cout << a; goto time; } break; return 0; }
Q12
Which operator is used as catch-all handler?
Q13
What does this template function indicates? ================== template<class T, class U> U func(T a, U b) { cout<<a<<"\t"<<b; } ==================
Q14
Which header file is used for the numeric limits in C++?
Q15
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; int main() { string s = "a long string"; s.insert(s.size() / 2, " * "); cout << s << endl; return 0; }
Q16
How many ways of reusing are there in the class hierarchy?
Q17
How many parameters are there in getline function?
Q18
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); for(int i=0;i<v.size();i++) cout<<v[i]<<" "; cout<<endl; v.assign(3, 8); for(int i=0;i<v.size();i++) cout<<v[i]<<" "; cout<<endl; return 0; }
Q19
What will be the output of the following C++ code? #include <iostream> using namespace std; template<typename T> inline T square(T x) { T result; result = x * x; return result; }; int main() { int i, ii; float x, xx; double y, yy; i = 2; x = 2.2; y = 2.2; ii = square(i); cout << i << " " << ii << endl; yy = square(y); cout << y << " " << yy << endl; }
Q20
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; int main () { int num = 3; string str_bad = "wrong number used"; try { if ( num == 1 ) { throw 5; } if ( num == 2 ) { throw 1.1f; } if ( num != 1 || num != 2 ) { throw str_bad; } } catch (int a) { cout << "Exception is: " << a << endl; } catch (float b) { cout << "Exception is: " << b << endl; } catch (...) { cout << str_bad << endl; } return 0; }
Q21
What will be the output of the following C++ code? #include <iostream> #include <vector> using namespace std; int main () { vector<int> myvector; myvector.push_back(78); myvector.push_back(16); myvector.front() += myvector.back(); cout << myvector.front() << '\n'; return 0; }
Q22
What is the default operation of adjacent_difference function in numeric library?
Q23
What will be the output of the following C++ code? #include <iostream> #include <algorithm> #include <vector> using namespace std; int main () { vector<int> v = {4,2,10,5,1,8}; sort(v.begin(), v.end()); if (binary_search(v.begin(), v.end(), 4)) cout << "found.\n"; else cout << "not found.\n"; return 0; }
Q24
How many types of Association can be there between classes?
Q25
What will be the output of the following C++ code? #include <iostream> #include <algorithm> #include <vector> using namespace std; bool IsOdd (int i) { return (i%2)==1; } int main () { vector<int> v = {4,2,10,5,1,8}; for(int i=0;i<v.size();i++) cout<<v[i]<<" "; cout<<endl; sort(v.begin(), v.end()); for(int i=0;i<v.size();i++) cout<<v[i]<<" "; return 0; }