Question 1 of 25
Hints left: 3
Q1
What will be the output of the following C++ codes? i. #ifndef Exercise_H #define Exercise_H int number = 842; #endif ii. #include <iostream> #include "exe.h" using namespace std; int main(int argc, char * argv[] ) { cout << number++; return 0; }
Q2
What will be the output of the following C++ code? #include <iostream> using namespace std; int main () { try { throw 20; } catch (int e) { cout << "An exception occurred " << e << endl; } return 0; }
Q3
Which operator is used in pointer to member function?
Q4
What will be the output of the following C++ code? #include <iostream> using namespace std; template <class T> class Test { private: T val; public: static int count; Test() { count++; } }; template<class T> int Test<T>::count = 0; int main() { Test<int> a; Test<int> b; Test<double> c; cout << Test<int>::count << endl; cout << Test<double>::count << endl; return 0; }
Q5
What is the lifetime of the element in container?
Q6
How to declare a template?
Q7
What will be the output of the following C++ code? #include <iostream> #include <map> using namespace std; int main () { multimap<char, int> mymultimap; mymultimap.insert(make_pair('y', 202)); mymultimap.insert(make_pair('y', 252)); pair<char, int> highest = *mymultimap.rbegin(); multimap<char, int> :: iterator it = mymultimap.begin(); do { cout << (*it).first << " => " << (*it).second << '\n'; } while ( mymultimap.value_comp()(*it++, highest) ); return 0; }
Q8
Which keyword is used to handle the expection?
Q9
What will be the output of the following C++ function? #include <iostream> using namespace std; template <typename T> T max(T x, T y) { return (x > y)? x : y; } int main() { cout << max(3, 7) << std::endl; cout << max(3.0, 7.0) << std::endl; cout << max(3, 7.0) << std::endl; return 0; }
Q10
Which of the following is correct about templates?
Q11
What will be the output of the following C++ code? #include <iostream> using namespace std; int main () { int n; n = 43; cout << hex << n << endl; return 0; }
Q12
What will be the output of the following C++ code? #include <iostream> #include <vector> #include <algorithm> using namespace std; int main(int argc, char const *argv[]) { vector <int> v = {1,5,23,90,15,35}; make_heap(v.begin(),v.end()); v.push_back(110); push_heap(v.begin(), v.end()); cout<<v.front(); }
Q13
Pick the correct statement.
Q14
What will be the output of the following C++ code? #include <iostream> #include <exception> using namespace std; int main () { try { double* i= new double[1000]; cout << "Memory allocated"; } catch (exception& e) { cout << "Exception arised: " << e.what() << endl; } return 0; }
Q15
Where are allocators implemented?
Q16
What kind of execution does sequence point allow?
Q17
What is the syntax of an explicit call for a template? Assume the given template function. template<class T, class U> void func(T a, U b) { cout<<a<<"\t"<<b<<endl; }
Q18
Aggregation is a . . . . . . . . type of Association relationship.
Q19
Which is the correct statement about pure virtual functions?
Q20
How many parameters are present in mismatch method in non-sequence modifying algorithm?
Q21
The C++ code which causes abnormal termination/behaviour of a program should be written under . . . . . . . . block.
Q22
What will be the output of the following C++ code? #include <iostream> using namespace std; class A { public: A(int n ) { cout << n; } }; class B: public A { public: B(int n, double d) : A(n) { cout << d; } }; class C: public B { public: C(int n, double d, char ch) : B(n, d) { cout <<ch; } }; int main() { C c(5, 4.3, 'R'); return 0; }
Q23
What type of class member is operator new?
Q24
Which of the following is correct about the map and unordered map?
Q25
How many Engine Adaptors are there in C++?