Question 1 of 25
Hints left: 3
Q1
What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { try { throw 1; } catch (int a) { cout << "exception number: " << a << endl; return 0; } cout << "No exception " << endl; return 0; }
Q2
What will be the output of the following C++ code? #include <iostream> #include <exception> using namespace std; class myexception: public exception { virtual const char* what() const throw() { return "exception arised"; } } myex; int main () { try { throw myex; } catch (exception& e) { cout << e.what() << endl; } return 0; }
Q3
What is the use of emplace() function?
Q4
To which type of class, We can apply RTTI?
Q5
Which are instances of a class with member function operator() when it is defined?
Q6
Which of the following is used for generic programming?
Q7
What will be the output of the following C++ code? #include <iostream> #include <string> #include <algorithm> using namespace std; int main() { string s = "spaces in text"; s.erase(remove(s.begin(), s.end(), ' ' ), s.end() ) ; cout << s << endl; }
Q8
What will be the output of the following C++ code? #include <iostream> using namespace std; class BaseClass { int i; public: void setInt(int n); int getInt(); }; class DerivedClass : public BaseClass { int j; public: void setJ(int n); int mul(); }; void BaseClass::setInt(int n) { i = n; } int BaseClass::getInt() { return i; } void DerivedClass::setJ(int n) { j = n; } int DerivedClass::mul() { return j * getInt(); } int main() { DerivedClass ob; ob.setInt(10); ob.setJ(4); cout << ob.mul(); return 0; }
Q9
What is the use of vector arithmetic in c++?
Q10
Which function is used to check whether a given sequence is heap or not?
Q11
What will be the output of the following C++ code? #include<iostream> #include<any> using namespace std; int main() { int a = 5; any var = a; cout<<var<<endl; return 0; }
Q12
In how many ways templates concept can be used?
Q13
Which parameter is legal for non-type template?
Q14
Map is implemented using . . . . . . . .
Q15
Which operator is used to access the nth bit in a bitset?
Q16
How many types are there in binary heaps?
Q17
How many types of exception handling are there in c++?
Q18
What will be the output of the following C++ code? #include <iostream> #include<type_traits> using namespace std; class Base { public: virtual void function1() {}; virtual void function2() {}; }; int main() { Base b; cout<<sizeof(b); return 0; }
Q19
What will be the output of the following C++ code? #include<iostream> #include <fstream> using namespace std; int main () { ofstream outfile ("test.txt"); for (int n = 0; n < 100; n++) { outfile << n; outfile.flush(); } cout << "Done"; outfile.close(); return 0; }
Q20
Which function is invoked when we try to throw an exception that is not supported by a function?
Q21
The if..else statement can be replaced by which operator?
Q22
What is the use of fill() function in array class?
Q23
What will be the output of the following C++ code? #include <iostream> using namespace std; int main () { int i; cout << "Please enter an integer value: "; cin >> i + 4; return 0; }
Q24
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); cout<<v.capacity()<<endl; v.resize(4); cout<<v.capacity()<<endl; return 0; }
Q25
Which one is always faster in writing on C++?