Question 1 of 25
Hints left: 3
Q1
What will be the output of the following C++ code? #include <iostream> #include <exception> using namespace std; struct MyException : public exception { const char * what () const throw () { return "C++ Exception"; } }; int main() { try { throw MyException(); } catch(MyException& e) { cout << "Exception caught" << std::endl; cout << e.what() << std::endl; } catch(std::exception& e) { } }
Q2
Which of the header file is used for array type manipulation?
Q3
What will be the output of the following C++ code? #include <iostream> using namespace std; template <typename T, typename U> void squareAndPrint(T x, U y) { cout << x << x * x << endl; cout << y << " " << y * y << endl; }; int main() { int ii = 2; float jj = 2.1; squareAndPrint<int, float>(ii, jj); }
Q4
Which is used to describe the function using placeholder types?
Q5
What are binary functors?
Q6
What will be the output of the following C++ code? #include<iostream> #include<iterator> #include<vector> using namespace std; int main() { vector<int> ar = { 1, 2, 3, 4, 5 }; vector<int>::iterator ptr = ar.begin(); ptr = next(ptr, 3); cout << *ptr << endl; return 0; }
Q7
Where does the vector add the item?
Q8
What is the correct statement about lambda expression?
Q9
Which type of relationship is modelled by Association?
Q10
What is the use of swap() function in array class?
Q11
Which operator is used to create the user-defined streams in c++?
Q12
What will be the output of the following C++ code? #include <iostream> #include <algorithm> #include <vector> using namespace std; int main () { vector<int> myvector (5); fill (myvector.begin(), myvector.begin() + 4, 5); fill (myvector.begin() + 3,myvector.end() - 2, 8); for (vector<int> :: iterator it = myvector.begin(); it != myvector.end(); ++it) cout << ' ' << *it; return 0; }
Q13
Which operators are used in the free store?
Q14
In nested try-catch block, if the inner catch block gets executed, then . . . . . . . .
Q15
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; int main() { cout<<extent<remove_extent<string[10][20]>::type>::value; cout<<extent<remove_extent<string[10][20][30]>::type>::value; return 0; }
Q16
What will be the output of the following C++ code? #include <iostream> #include <utility> using namespace std; int main () { pair <int,int> p(1,2); cout<<"Pair(first,second) = ("<<p.first<<","<<p.second<<")\n"; return 0; }
Q17
What will be the output of the following C++ code? #include <iostream> #include <utility> #include <string> using namespace std; int main () { pair <int,int> p1(1,2); pair <int,int> p2(3,4); cout<<"Pair(first,second) = ("<<p1.first<<","<<p1.second<<")\n"; p1.swap(p2); cout<<"Pair(first,second) = ("<<p1.first<<","<<p1.second<<")\n"; return 0; }
-
A
-
B
-
C
-
D
Q18
Which of the follwoing function(s) of Array classes are similar to [] operator?
Q19
What is the name of the myfile2 file after executing the following C++ code? #include <stdio.h> int main () { int result; char oldname[] = "myfile2.txt"; char newname[] = "newname.txt"; result = rename(oldname, newname ); if (result == 0) puts ( "success" ); else perror( "Error" ); return 0; }
Q20
What will be the output of the following C++ code? #include <iostream> using namespace std; class Test1 { }; class Test2 : public Test1 { }; void Funct(); int main() { try { Funct(); } catch (const Test1&) { cerr << "Caught a exception" << endl; } return 0; } void Funct() { throw Test2(); }
Q21
Why do we need relationships between classes?
Q22
Which operator is used to allocate the memory?
Q23
What is meant by permutation in c++?
Q24
What is the syntax of class template?
Q25
Which algorithm is used in subtract_with_carry_engine?