Question 1 of 25
Hints left: 3
Q1
How many constructors can present in a class?
Q2
What will be the output of the following C++ code? #include <iostream> using namespace std; class X { public: int a; void f(int b) { cout<< b << endl; } }; int main() { int X :: *ptiptr = &X :: a; void (X :: * ptfptr) (int) = &X :: f; X xobject; xobject.*ptiptr = 10; cout << xobject.*ptiptr << endl; (xobject.*ptfptr) (20); }
Q3
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; int main() { cout<<extent<remove_all_extents<string[10][20][30]>::type>::value; return 0; }
Q4
When do we call that resource is leaked?
Q5
What is the use of adapter in STL in c++?
Q6
What will be the output of the following C++ code? #include <iostream> #include <algorithm> #include <vector> using namespace std; int main () { int first[] = {5, 10, 15, 20, 25}; int second[] = {50, 40, 30, 20, 10}; vector<int> v(10); vector<int> :: iterator it; sort (first, first + 5); sort (second, second + 5); it = set_union (first, first + 5, second, second + 5, v.begin()); v.resize(it-v.begin()); for (it = v.begin(); it != v.end(); ++it) cout << ' ' << *it; cout << '\n'; return 0; }
Q7
What will be the output of the following C++ code? #include <iostream> using namespace std; class Base { protected: int a; public: Base() { a = 34; } Base(int i) { a = i; } virtual ~Base() { if (a < 0) throw a; } virtual int getA() { if (a < 0) { throw a; } } }; int main() { try { Base b(-25); cout << endl << b.getA(); } catch (int) { cout << endl << "Illegal initialization"; } }
Q8
Which function is used to check whether a character is an alphabet or number?
Q9
Which function is used increment the iterator by a particular value?
Q10
What is a function template?
Q11
What will be the output of the following C++ code? #include <iostream> #include <algorithm> #include <vector> using namespace std; bool myfunction (int i, int j) { return (i==j); } int main () { int myints[] = {10, 20, 20, 20, 30, 30, 20, 20, 10}; vector<int> myvector (myints, myints + 9); vector<int> :: iterator it; it = unique (myvector.begin(), myvector.end()); myvector.resize( distance(myvector.begin(), it) ); unique (myvector.begin(), myvector.end(), myfunction); for (it = myvector.begin(); it != myvector.end(); ++it) cout << ' ' << *it; return 0; }
Q12
What will be the output of the following C++ code? #include <iostream> #include <string> #include <tuple> using namespace std; int main() { tuple <int, string> tp1; tuple <int, string> tp2; tp1 = make_tuple(0, "Hello"); tp2 = make_tuple(1, "World"); auto tp3 = tuple_cat(tp1, tp2); cout<<"("<<get<0>(tp3)<<", "<<get<1>(tp3)<<", "<<get<2>(tp3)<<", "<<get<3>(tp3)<<")"<<endl; return 0; }
Q13
Which function is used to access the last element of an array class?
Q14
Indexing of bitset variables starts from . . . . . . . .
Q15
How many types of specialization are there in c++?
Q16
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 = advance(ptr, 2); cout << *ptr << endl; return 0; }
Q17
What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int x = -1; char *ptr; ptr = new char[256]; try { if (x < 0) { throw x; } if (ptr == NULL) { throw " ptr is NULL "; } } catch (...) { cout << "Exception occurred: exiting "<< endl; } return 0; }
Q18
What will be the output of the following C++ code if the following arguments are executed on terminal? ===============program.cpp============= #include <iostream> using namespace std; int main(int argc, char const *argv[]) { for(int i=0;i<argc;i++) cout<<argv[i]<<"\n"; } ======================================= ================commands=============== $ g++ program.cpp -o output $ ./output Hello World =======================================
Q19
Which function is used to check whether the vector is empty or not?
Q20
What will be the output of the following C++ code? #include <iostream> #include <locale> using namespace std; int main() { locale mylocale(""); cout.imbue( mylocale ); cout << (double) 3.14159 << endl; return 0; }
Q21
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(10); mypq.push(20); mypq.push(15); cout << mypq.top() << endl; return 0; }
Q22
Which objects information is loaded in locale object?
Q23
Which of the following is correct about the first parameter of the main function?
Q24
By using which function does the buffer are automatically flushed?
Q25
What of the following is the equivalent statement for the functor call, x = f(arg1, arg2); where f is a functor and arg1 and arg2 are the arguments required by the functors?