Question 1 of 25
Hints left: 3
Q1
At which time does the static_cast can be applied?
Q2
What will be the output of the following C++ code? #include <iostream> #include <algorithm> #include <vector> using namespace std; bool mygreater (int i,int j) { return (i > j); } int main () { int myints[] = {10, 20, 30, 30, 20, 10, 10, 20}; vector<int> v(myints, myints + 8); pair<vector<int> :: iterator, vector<int> :: iterator> bounds; sort (v.begin(), v.end()); bounds = equal_range (v.begin(), v.end(), 20); cout << (bounds.first - v.begin()); cout << " and " << (bounds.second - v.begin()) << '\n'; return 0; }
Q3
What will be the output of the following C++ code? #include <iostream> #include <exception> using namespace std; void myunexpected () { cout << "unexpected handler called\n"; throw; } void myfunction () throw (int,bad_exception) { throw 'x'; } int main (void) { set_unexpected (myunexpected); try { myfunction(); } catch (int) { cout << "caught int\n"; } catch (bad_exception be) { cout << "caught bad_exception\n"; } catch (...) { cout << "caught other exception \n"; } return 0; }
Q4
Which operator is used to take OR of two bitset variables?
Q5
What will be the output of the following C++ code? #include<iostream> using namespace std; int main() { int a = 5; auto check = [](int x) { if(x == 0) return false; else return true; }; cout<<check(a)<<endl; return 0; }
Q6
Sets are implemented using . . . . . . . .
Q7
Which of the following operations can be performed on a pair?
Q8
Which container is used to keep priority based elements?
Q9
What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; template<class T> class A { T a; public: A(){} ~A(){} }; int main(int argc, char const *argv[]) { A <char>a1; A <int>a2; A <double>a3; cout<<sizeof(a1)<<endl; cout<<sizeof(a2)<<endl; cout<<sizeof(a3)<<endl; return 0; }
Q10
Which of the following is correct about swap()?
Q11
To which type does the numeric limits are suitable?
Q12
What will be the output of the following C++ code? #include <iostream> #include <algorithm> #include <vector> using namespace std; int main () { int myints[] = {10, 20, 30, 5, 15}; vector<int> v(myints, myints + 5); make_heap (v.begin(), v.end()); pop_heap (v.begin(), v.end()); v.pop_back(); v.push_back(99); push_heap (v.begin(), v.end()); sort_heap (v.begin(), v.end()); for (unsigned i = 0; i < v.size(); i++) cout << ' ' << v[i]; return 0; }
Q13
Which type of list a Forward_list sequence container implements?
Q14
What will be the output of the following C++ code? #include <iostream> #include <fstream> using namespace std; int main () { int length; char * buffer; ifstream is; is.open ("sample.txt", ios :: binary ); is.seekg (0, ios :: end); length = is.tellg(); is.seekg (0, ios :: beg); buffer = new char [length]; is.read (buffer, length); is.close(); cout.write (buffer, length); delete[] buffer; return 0; }
Q15
The switch statement is also called as?
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"; throw; } } catch (int x) { cout << "Outer Catch\n"; } return 0; }
Q17
What will happen when we use void in argument passing?
Q18
Which of the following is the correct way of declaring a tuple?
Q19
How many levels are there in exception safety?
Q20
What is the function of shift()?
Q21
What will be the output of the following C++ code? #include <iostream> using namespace std; class stu { protected: int rno; public: void get_no(int a) { rno = a; } void put_no(void) { } }; class test:public stu { protected: float part1,part2; public: void get_mark(float x, float y) { part1 = x; part2 = y; } void put_marks() { } }; class sports { protected: float score; public: void getscore(float s) { score = s; } void putscore(void) { } }; class result: public test, public sports { float total; public: void display(void); }; void result::display(void) { total = part1 + part2 + score; put_no(); put_marks(); putscore(); cout << "Total Score=" << total << "\n"; } int main() { result stu; stu.get_no(123); stu.get_mark(27.5, 33.0); stu.getscore(6.0); stu.display(); return 0; }
Q22
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; int main() { cout<<is_array<int>::value; cout<<is_array<char[10]>::value; cout<<is_array<string>::value; return 0; }
Q23
Which of the following library is used to do vector arithmetic?
Q24
What will be the output of the following C++ code? #include <iostream> using namespace std; template<typename type> class TestVirt { public: virtual type TestFunct(type Var1) { return Var1 * 2; } }; int main() { TestVirt<int> Var1; cout << Var1.TestFunct(100) << endl; return 0; }
Q25
Which function is used to check whether a character is tab or space or whitespace control code(\n,\r,etc.)?