Question 1 of 25
Hints left: 3
Q1
What are unary functors?
Q2
What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; template<class T, class U = char> class A { T a; U b; public: A(T a_val, char b_val = '$'){ this->a = a_val; this->b = b_val; } void print(){ cout<<a<<' '<<b<<endl; } }; int main(int argc, char const *argv[]) { A <int, int> a1(5,10); A <int> a2(5); A <float> a3(10.0); a1.print(); a2.print(); a3.print(); return 0; }
Q3
What will be the output of the following C++ code? #include <iostream> using namespace std; void Division(const double a, const double b); int main() { double op1=0, op2=10; try { Division(op1, op2); } catch (const char* Str) { cout << "\nBad Operator: " << Str; } return 0; } void Division(const double a, const double b) { double res; if (b == 0) throw "Division by zero not allowed"; res = a / b; cout << res; }
Q4
What will be the output of the following C++ code? #include <iostream> #include <iomanip> using namespace std; void showDate(int m, int d, int y) { cout << setfill('0'); cout << setw(2) << m << '/' << setw(2) << d << '/' << setw(4) << y << endl; } int main() { showDate(1, 1, 2013); return 0; }
Q5
What will be the output of the following C++ code? #include <iostream> using namespace std; class sample { public: virtual void example() = 0; }; class Ex1:public sample { public: void example() { cout << "ubuntu"; } }; class Ex2:public sample { public: void example() { cout << " is awesome"; } }; int main() { sample* arra[2]; Ex1 e1; Ex2 e2; arra[0]=&e1; arra[1]=&e2; arra[0]->example(); arra[1]->example(); }
Q6
What is the benefit of c++ input and output over c input and output?
Q7
What is meant by heap?
Q8
What happens when no argument is supplied to reset() function?
Q9
How many template parameters are allowed in template classes?
Q10
What is vtable in C++?
Q11
What is the use of the allocator interface in the user-defined container?
Q12
What will be the output of the following C++ code? #include <iostream> #include <iterator> #include <vector> using namespace std; int main () { vector<int> myvector; for (int i = 1; i < 4; ++i) myvector.push_back(i*10); ostream_iterator<int> out_it (cout,", "); copy ( myvector.begin(), myvector.end(), out_it ); return 0; }
Q14
What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; template<class T> class A { public: T func(T a, T b){ return a/b; } }; int main(int argc, char const *argv[]) { A <char>a1; cout<<a1.func(65,1)<<endl; cout<<a1.func(65.28,1.1)<<endl; return 0; }
Q15
Which container provides random access iterators?
Q16
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.cshift(-3); for (int &x: varr) cout << x << " "; return 0; }
Q17
How many Pseudo-random number engines are there?
Q18
What will happen if the iterator is unchecked?
Q19
What will be the output of the following C++ code? #include <iostream> using namespace std; double division(int a, int b) { if ( b == 0 ) { throw "Division by zero condition!"; } return (a / b); } int main () { int x = 50; int y = 0; double z = 0; try { z = division(x, y); cout << z << endl; } catch (const char* msg) { cout << msg << endl; } return 0; }
Q20
How the template class is different from the normal class?
Q21
Which function is used to check whether a character is an alphabet?
Q22
Unordered map is implemented using . . . . . . . .
Q23
Which is also called as abstract class?
Q24
What is the user-defined header file extension in c++?
Q25
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> arr = {1,2,3,4,5}; cout<<"Printing Using [] operator: "; for(int i=0;i<5;i++){ cout<<arr[i]<<" "; } cout<<endl; cout<<"Printing Using at() function: "; for(int i=0;i<5;i++){ cout<<arr.at(i)<<" "; } cout<<endl; return 0; }