Question 1 of 25
Hints left: 3
Q1
What will happen when introduce the interface of classes in a run-time polymorphic hierarchy?
Q2
Which of the following describes the protected access specifier?
Q3
Which interface in the container is required for storage management?
Q4
What will be the output of the following C++ code? #include <iostream> #include <string> #include <sstream> using namespace std; int main () { string mystr; float price = 0; int quantity = 0; cout << "Enter price: "; getline (cin, mystr); stringstream(mystr) >> price; cout << "Enter quantity: "; getline (cin, mystr); stringstream(mystr) >> quantity; cout << "Total price: " << price * quantity << endl; return 0; }
Q5
Which interface determines how your class will be used by another program?
Q6
What will be the output of the following C++ code? #include <iostream> #include <set> using namespace std; int main() { set<int> tst; tst.insert(12); tst.insert(21); tst.insert(32); tst.insert(31); set<int> :: const_iterator pos; for(pos = tst.begin(); pos != tst.end(); ++pos) cout << *pos << ' '; return 0; }
Q7
What will be the output of the following C++ code? #include <iostream> #include <functional> #include <algorithm> using namespace std; int main () { int first[] = {10, 40, 90}; int second[] = {1, 2, 3}; int results[5]; transform ( first, first + 5, second, results, divides<int>()); for (int i = 0; i < 3; i++) cout << results[i] << " "; return 0; }
Q8
How many runtime error messages associated with exception?
Q9
Which is used to use a function from one source file to another?
Q10
What is the use of the function "showbase"?
Q11
Which is used for formatting purpose in c++?
Q12
Which of the following is the correct syntax of accessing the first element of a pair p?
Q13
What will be the output of the following C++ code? #include <iostream> using namespace std; void PrintSequence(int StopNum) { int Num; Num = 1; while (true) { if (Num >= StopNum) throw Num; cout << Num << endl; Num++; } } int main(void) { try { PrintSequence(2); } catch(int ExNum) { cout << "exception: " << ExNum << endl; } return 0; }
Q14
What will be the output of the following C++ code? #include <iostream> using namespace std; template<typename type> class Test { public: Test() { }; ~Test() { }; type Funct1(type Var1) { return Var1; } type Funct2(type Var2) { return Var2; } }; int main() { Test<int> Var1; Test<float> Var2; cout << Var1.Funct1(200) << endl; cout << Var2.Funct2(3.123) << endl; return 0; }
Q15
Which of the following can derived class inherit?
Q16
What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { try { try { throw 20; } catch (int n) { cout << "Inner Catch\n"; } } catch (int x) { cout << "Outer Catch\n"; } return 0; }
Q17
What will be the output of the following C++ code? #include <iostream> using namespace std; template <typename T> void fun(const T&x) { static int count = 0; cout << "x = " << x << " count = " << count; ++count; return; } int main() { fun<int> (1); cout << endl; fun<int>(1); cout << endl; fun<double>(1.1); cout << endl; return 0; }
Q18
What will be the output of the following C++ code? #include <iostream> #include<type_traits> using namespace std; class Base { public: }; int main() { Base b; cout<<sizeof(b); return 0; }
Q19
What happens when no argument is supplied to flip() function?
Q20
What will be the output of the following C++ code? #include <iostream> #include <algorithm> using namespace std; int main () { int myints[] = {1, 2, 3}; sort (myints, myints + 3); do { } while ( next_permutation(myints, myints + 3) ); cout << myints[0] << ' ' << myints[1] << ' ' << myints[2] << '\n'; return 0; }
Q21
How the size of a vector increases once it is full?
Q22
What will be the output of the following C++ code? #include <iostream> #include <bitset> using namespace std; int main() { bitset<8> b1(20); cout<<b1.none(); cout<<b1.any(); }
Q23
Which of the things does not require instantiation?
Q24
What will be the output of the following C++ code? #include <iostream> #include <vector> using namespace std; int main () { vector<int> a (3, 0); vector<int> b (5, 0); b = a; a = vector<int>(); cout << "Size of a " << int(a.size()) << '\n'; cout << "Size of b " << int(b.size()) << '\n'; return 0; }
Q25
Which is the correct way of handling arguments with spaces?