Question 1 of 25
Hints left: 3
Q1
Pick the incorrect statement about inline functions in C++?
Q2
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; int main () { string str ("nobody does like this"); string key ("nobody"); size_t f; f = str.rfind(key); if (f != string::npos) str.replace (f, key.length(), "everybody"); cout << str << endl; return 0; }
Q3
What will be the output of the following C++ code? #include <iostream> using namespace std; int operate (int a, int b) { return (a * b); } float operate (float a, float b) { return (a / b); } int main () { int x = 5, y = 2; float n = 5.0, m = 2.0; cout << operate (x, y); cout << operate (n, m); return 0; }
Q4
In which form does the function call operator can be overloaded?
Q5
What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { typedef int num; num a = 10, b = 15; num c = a + b + a - b; cout << c; return 0; }
Q6
What is the use of function call operator?
Q7
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class B { int b; public: B(int i){ b = i; } }; class C { B b; public: C(int i){ b = B(i); } friend void show(); }; void show() { C c(10); cout<<"value of b is: "<<c.b.b<<endl; } int main(int argc, char const *argv[]) { show(); return 0; }
Q8
What is the syntax of user-defined data types?
Q9
What is the correct syntax of accessing a static member of a Class? --------------------------- Example class: class A { public: static int value; } ---------------------------
Q10
How to stop your program from eating so much ram?
Q11
What will be the output of the following C++ code? #include <iostream> using namespace std; class number { int i; public: int geti(); void puti(int j); }; int number::geti() { return i; } void number::puti(int j) { i = j; } int main() { number s; s.puti(10); cout << s.geti( ); return 0; }
Q12
What are the essential operators in c++?
Q13
Pick out the compound assignment statement.
Q14
How many objects can present in a single class?
Q15
Pick out the correct syntax of operator conversion.
Q16
What do we need to do to pointer for overloading the subscript operator?
Q17
What will be the output of the following C++ code? #include <iostream> using namespace std; class myclass { public: int i; myclass *operator->() {return this;} }; int main() { myclass ob; ob->i = 10; cout << ob.i << " " << ob->i; return 0; }
Q18
Which is used to pass the large objects in c++?
Q19
Operator overloading is . . . . . . . .
Q20
What will be the output of the following C++ code? #include <iostream> using namespace std; class sample { int width, height; public: void set_values (int, int); int area () {return (width * height);} friend sample duplicate (sample); }; void sample::set_values (int a, int b) { width = a; height = b; } sample duplicate (sample rectparam) { sample rectres; rectres.width = rectparam.width * 2; rectres.height = rectparam.height * 2; return (rectres); } int main () { sample rect, rectb; rect.set_values (2, 3); rectb = duplicate (rect); cout << rectb.area(); return 0; }
Q21
What will be the output of the following C++ code? #include <iostream> using namespace std; class Box { public : double length; double breadth; double height; }; int main( ) { Box Box1; double volume; Box1.height = 5; Box1.length = 6; Box1.breadth = 7.1; volume = Box1.height * Box1.length * Box1.breadth; cout << "Volume of Box1 : " << volume <<endl; return 0; }
Q22
Identify the correct statement.
Q23
How the objects are self-referenced in a member function of that class.
Q24
How many member functions are there in this C++ class excluding constructors and destructors? class Box { int capacity; public: void print(); friend void show(); bool compare(); friend bool lost(); };
Q25
What will be the output of the following C++ code? #include <iostream> #include <complex> using namespace std; int main() { complex<double> c_double(2, 3); complex<int> c_int(4, 5); c_double *= 2; c_double = c_int; cout << c_double; return 0; }