Question 1 of 25
Hints left: 3
Q1
What will be the output of the following C++ code? #include <iostream> using namespace std; template <typename T, int count> void loopIt(T x) { T val[count]; for(int ii = 0; ii < count; ii++) { val[ii] = x++; cout << val[ii] << endl; } }; int main() { float xx = 2.1; loopIt<float, 3>(xx); }
Q2
How does a sequence of objects are accessed in c++?
Q3
What will be the output of the following C++ code? #include <iostream> using namespace std; template <class type> class Test { public: Test(); ~Test(); type Data(type); }; template <class type> type Test<type>::Data(type Var0) { return Var0; } template <class type> Test<type>::Test() { } template <class type> Test<type>::~Test() { } int main(void) { Test<char> Var3; cout << Var3.Data('K') << endl; return 0; }
Q4
What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { try { try { throw 20; } catch (char n) { cout << "Inner Catch\n"; } } catch (int x) { cout << "Outer Catch\n"; } return 0; }
Q5
What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int x = -1; try { if (x < 0) { throw x; } else { cout<<x; } } catch (int x ) { cout << "Exception occurred: Thrown value is " << x << endl; } return 0; }
Q6
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; int main() { cout<<extent<string[10][20][30], 0>::value; cout<<extent<string[10][20][30], 1>::value; cout<<extent<string[10][20][30], 2>::value; return 0; }
Q7
What happens when only one argument is supplied to set() function?
Q8
Which will be used with physical devices to interact from C++ program?
Q9
What is the class relationship?
Q10
What will be the output of the following C++ code? #include <iostream> #include <vector> using namespace std; int main () { vector<int> myvector; int * p; unsigned int i; p = myvector.get_allocator().allocate(5); for (i = 0; i < 5; i++) myvector.get_allocator().construct(&p[i], i); for (i = 0; i < 5; i++) cout << ' ' << p[i]; for (i = 0; i < 5; i++) myvector.get_allocator().destroy(&p[i]); myvector.get_allocator().deallocate(p, 5); return 0; }
Q11
How many indicators are available in c++?
Q12
What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { unsigned long x = 64; cout << x << oct << x << endl; return 0; }
Q13
What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; template<class T> T func(T a) { return a; } template<class T, class U> T func(U a) { return (T)a; } int main(int argc, char const *argv[]) { int a = 5; int b = func(a); int c = func(5.5); cout<<b<<c<<endl; return 0; }
Q14
What will be the output of the following C++ code? #include <iostream> #include <functional> #include <algorithm> using namespace std; int main () { int numbers[] = {3, -4, -5}; transform ( numbers, numbers + 3, numbers, negate<int>() ); for (int i = 0; i < 3; i++) cout << numbers[i] << " "; }
Q15
In which context does the stack operates?
Q16
Which function is used to get the real part of the complex number?
Q17
Which function is used to calculate the conjugate of a complex number?
Q18
How many types of the constructor are there in C++?
Q19
What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { char* ptr; unsigned long int Test = sizeof(size_t(0) / 3); cout << Test << endl; try { ptr = new char[size_t(0) / 3]; delete[ ] ptr; } catch (bad_alloc &thebadallocation) { cout << thebadallocation.what() << endl; }; return 0; }
Q20
Which function can be used to find the sum of a vector container?
Q21
What will be the output of the following C++ code? #include <iostream> #include <exception> using namespace std; void myunexpected () { cout << "unexpected called\n"; throw 0; } void myfunction () throw (int) { throw 'x'; } int main () { set_unexpected (myunexpected); try { myfunction(); } catch (int) { cout << "caught int\n"; } catch (...) { cout << "caught other exception\n"; } return 0; }
Q22
How many list sequence containers are provided by STL?
Q23
Which of the following statements are correct about Catch handler? i. It must be placed immediately after the try block ii. It can have more than one parameters iii. There must be one and only one catch handler for every try block iv. There can be multiple catch handler for a try block v. General catch handler can be kept anywhere after try block.
Q24
What will be the output of the following C++ code? #include <iostream> #include <iterator> #include <vector> using namespace std; int main () { vector<int> myvector; for (int i = 0; i < 10; i++) myvector.push_back(i); typedef vector<int> :: iterator iter_int; reverse_iterator<iter_int> rev_iterator; rev_iterator = myvector.rend() - 4; cout << *rev_iterator << endl; return 0; }
Q25
What will be the output of the following C++ code? #include <iostream> using namespace std; int main () { char first, second; cout << "Enter a word: "; first = cin.get(); cin.sync(); second = cin.get(); cout << first << endl; cout << second << endl; return 0; }