Question 1 of 25
Hints left: 3
Q1
Exception handlers are declared with . . . . . . . . keyword.
Q2
How many number of spaces should be set in default tab?
Q3
How can object be allocated outside the object lifetime?
Q4
What are Bi-directional iterators?
Q5
What will be the output of the following C++ code? #include<iostream> #include<stdlib.h> using namespace std; template<class T, class U> class A { T x; U y; }; int main() { A<char, char> a; A<int, int> b; cout << sizeof(a) << endl; cout << sizeof(b) << endl; return 0; }
Q6
Which operator is used in priority queue?
Q7
What is the use of reset() function?
Q8
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); if(p1 <= p2) cout<<"P1 is small"; else cout<<"P2 is small"; return 0; }
Q9
What will be the output of the following C++ code? #include <iostream> using namespace std; class student { public: int rno , m1 , m2 ; protected: void get() { rno = 15, m1 = 10, m2 = 10; } }; class sports { public: int sm; void getsm() { sm = 10; } }; class statement : public student, public sports { int tot, avg; public: void display() { tot = (m1 + m2 + sm); avg = tot / 3; cout << tot; cout << avg; } void setObject() { get(); } }; int main() { statement obj; obj.setObject(); obj.getsm(); obj.display(); }
Q10
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); v.resize(4); for (auto it = v.begin(); it != v.end(); it++) cout << *it << " "; return 0; }
Q11
What will be the output of the following C++ code? #include <iostream> #include <Valarray> using namespace std; int main() { Valarray<int> varr = { 10, 2, 20, 1, 30 }; for (int &x: varr) cout << x << " "; cout<<endl; varr = varr.apply([](int x){return x+=5;}); for (int &x: varr) cout << x << " "; return 0; }
Q12
What will be the output of the following C++ code? #include<iostream> using namespace std; int main() { int a = 5; auto check = [&]() { a = 10; }; check(); cout<<"Value of a: "<<a<<endl; return 0; }
Q13
What is the use of the set() function in bitset?
Q14
What will be the output of the following C++ code? #include <iostream> #include <complex> using namespace std; int main() { complex <double> cn(3.0, 4.0); cout<<"proj"<<cn<<" : "<<proj(cn)<<endl; return 0; }
Q15
What will be the output of the following C++ code? #include <iostream> #include <vector> using namespace std; int main() { vector<int> v1; vector<char> v2; for (int i = 1; i <= 5; i++) v1.push_back(i); for (int i = 6; i <= 10; i++) v2.push_back(i); v1.swap(v2); for(int i=0;i<v1.size();i++) cout<<v1[i]<<" "; for(int i=0;i<v2.size();i++) cout<<v2[i]<<" "; cout<<endl; return 0; }
Q16
In sequence point, how will the overloaded operators behave like?
Q17
In nested try catch blocks, if both inner and outer catch blocks are unable to handle the exception thrown, then . . . . . . . .
Q18
What will be the output of the following C++ code? #include <iostream> #include <deque> using namespace std; int main () { deque<int> mydeque (5); deque<int>::reverse_iterator rit = mydeque.rbegin(); int i = 0; for (rit = mydeque.rbegin(); rit!= mydeque.rend(); ++rit) *rit = ++i; for (deque<int> :: iterator it = mydeque.begin(); it != mydeque.end(); ++it) cout << ' ' << *it; return 0; }
Q19
Return type of uncaught_exception() is . . . . . . . .
Q20
What is the name of the container which contains group of multiple objects?
Q21
What will be the output of the following C++ code? #include <typeinfo> #include <iostream> using namespace std; class A { public: virtual ~A(); }; int main() { A* a = NULL; try { cout << typeid(*a).name() << endl; } catch (bad_typeid) { cout << "Object is NULL" << endl; } }
Q22
What will be the output of the following C++ code? #include <iostream> using namespace std; void empty() throw() { cout << "In empty()"; } void with_type() throw(int) { cout << "Will throw an int"; throw(1); } int main() { try { empty(); with_type(); } catch (int) { cout << "Caught an int"; } }
Q23
Which header file is used to operate on numeric sequences?
Q24
What is the syntax of swap()?
Q25
What will be the output of the following C++ code? #include <iostream> using namespace std; class bowl { public: int apples; int oranges; }; int count_fruit(bowl * begin, bowl * end, int bowl :: *fruit) { int count = 0; for (bowl * iterator = begin; iterator != end; ++ iterator) count += iterator ->* fruit; return count; } int main() { bowl bowls[2] = {{ 1, 2 },{ 3, 5 }}; cout << "I have " << count_fruit(bowls, bowls + 2, & bowl :: apples) << " apples\n"; cout << "I have " << count_fruit(bowls, bowls + 2, & bowl :: oranges) << " oranges\n"; return 0; }