Question 1 of 25
Hints left: 3
Q1
What will be the output of the following C++ code? #include <new> #include <iostream> using namespace std; struct A { virtual ~A() { }; void operator delete(void* p) { cout << "A :: operator delete" << endl; } }; struct B : A { void operator delete(void* p) { cout << "B :: operator delete" << endl; } }; int main() { A* ap = new B; delete ap; }
Q2
Which operator is used to compare the values to find min and max?
Q3
What will be the output of the following C++ code? #include <iostream> using namespace std; template <class T> class XYZ { public: void putPri(); static T ipub; private: static T ipri; }; template <class T> void XYZ<T>::putPri() { cout << ipri++ << endl; } template <class T> T XYZ<T>::ipub = 1; template <class T> T XYZ<T>::ipri = 1.2; int main() { XYZ<int> a; XYZ<float> b; a.putPri(); cout << a.ipub << endl; b.putPri(); }
Q4
Which is dependant on template parameter?
Q5
Given below classes which of the following are the possible row entries in vtable of Base class? class Base { public: virtual void function1() {}; virtual void function2() {}; }; class D1: public Base { public: virtual void function1() {}; }; class D2: public Base { public: virtual void function2() {}; };
Q6
What will be the output of the following C++ code? #include <iostream> #include <array> using namespace std; int main(int argc, char const *argv[]) { array<int, 5> arr1; arr1.fill(2); for(int i=0;i<5;i++) cout<<arr1[i]; cout<<endl; return 0; }
Q7
What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; template<class T> class A { public: A(){ cout<<"Created\n"; } ~A(){ cout<<"Destroyed\n"; } }; int main(int argc, char const *argv[]) { A a; return 0; }
Q8
What will be the output of the following C++ code? #include <iostream> #include <algorithm> #include <vector> using namespace std; bool IsOdd (int i) { return ((i % 2) == 1); } int main () { vector<int> myvector; myvector.push_back(10); myvector.push_back(25); myvector.push_back(40); myvector.push_back(55); vector<int> :: iterator it = find_if (myvector.begin(), myvector.end(), IsOdd); cout << *it << '\n'; return 0; }
Q9
Which classes are called as mixin?
Q10
How are many number of characters available in newname.txt? #include <stdio.h> int main () { FILE * p; int n = 0; p = fopen ("newname.txt", "rb"); if (p == NULL) perror ("Error opening file"); else { while (fgetc(p) != EOF) { ++n; } if (feof(p)) { printf ("%d\n", n); } else puts ("End-of-File was not reached."); fclose (p); } return 0; }
Q11
What is the use of the flip function in bitset?
Q12
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; int main() { cout<<rank<remove_all_extents<string[10][20]>::type>::value; return 0; }
Q13
What will not be called when the terminate() is raised in the constructor?
Q14
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; int main() { double Op1 = 10, Op2 = 5, Res; char Op; try { if (Op != '+' && Op != '-' && Op != '*' && Op != '/') throw Op; switch(Op) { case '+': Res = Op1 + Op2; break; case '-': Res = Op1 - Op2; break; case '*': Res = Op1 * Op2; break; case '/': Res = Op1 / Op2; break; } cout << "\n" << Op1 << " " << Op << " "<< Op2 << " = " << Res; } catch (const char n) { cout << n << " is not a valid operator"; } return 0; }
Q15
Which header file is used for reading and writing to a file?
Q16
What do input and output objects support?
Q17
Which of the following will return the new element at the end of container?
Q18
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<<log(cn)<<endl; return 0; }
Q19
What will be the output of the following C++ code? #include<iostream> using namespace std; int main() { int a = 5; int b = 5; auto check = [&a]() { a = 10; b = 10; } check(); cout<<"Value of a: "<<a<<endl; cout<<"Value of b: "<<b<<endl; return 0; }
Q20
What will be the output of the following C++ code? #include <stdio.h> #include <stdlib.h> #include <ctype.h> int main () { char str[] = "ffff"; long int number; if (isxdigit(str[0])) { number = strtol (str, NULL, 16); printf ("%ld\n", number); } return 0; }
Q21
Which is used to handle the exceptions in c++?
Q22
In which of the following relationship objects of related classes can occur independently?
Q23
Which of the following is the correct syntax of declaring a complex number?
Q24
What is meant by hash tables in C++?
Q25
What can be used to input a string with blank space?