Question 1 of 25
Hints left: 3
Q1
What will be the output of the following C++ code? #include <iostream> using namespace std; class polygon { protected: int width, height; public: void set_values (int a, int b) { width = a; height = b;} }; class output1 { public: void output (int i); }; void output1::output (int i) { cout << i << endl; } class rectangle: public polygon, public output1 { public: int area () { return (width * height); } }; class triangle: public polygon, public output1 { public: int area () { return (width * height / 2); } }; int main () { rectangle rect; triangle trgl; rect.set_values (4, 5); trgl.set_values (4, 5); rect.output (rect.area()); trgl.output (trgl.area()); return 0; }
Q2
What is meant by multiple inheritance?
Q3
What happens if a virtual function is not overridden in the derived class in C++?
Q4
What is the use of the 'virtual' keyword in C++?
Q5
The concept of deciding which function to invoke during runtime is called . . . . . . . .
Q6
How is polymorphism implemented in C++?
Q7
What is polymorphism in C++?
Q8
How many specifiers are used to derive a class?
Q9
Which symbol is used to create multiple inheritances?
Q10
What is dynamic polymorphism in C++?
Q11
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class A { int a, b; float d; public: void change(int i){ a = i; } void value_of_a(){ cout<<a; } }; class B: private A { }; int main(int argc, char const *argv[]) { B b; cout<<sizeof(B); return 0; }
Q12
If a class is derived privately from a base class then . . . . . . . .
Q13
Which type of polymorphism is achieved by function overriding in C++?
Q14
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class Mammal { public: virtual void Define(){ cout<<"I'm a Mammal\n"; } }; class Human: public Mammal { public: void Define(){ cout<<"I'm a Human\n"; } }; class Male: public Human { public: void Define(){ cout<<"I'm a Male\n"; } }; class Female: public Human { public: void Define(){ cout<<"I'm a Female\n"; } }; int main(int argc, char const *argv[]) { Mammal *M; Male m; Female f; *M = m; M->Define(); return 0; }
Q15
What is the order of Constructors call when the object of derived class B is declared, provided class B is derived from class A?
Q16
What are the things are inherited from the base class?
Q17
Which concept of OOPs is shown by Virtual Functions?
Q18
Which type of polymorphism is achieved by function overloading in C++?
Q19
Which type of inheritance is necessary for achieving polymorphism in C++?
Q20
Which keyword is used to achieve runtime polymorphism in C++?
Q21
Virtual functions in C++ tells the compiler to perform . . . . . . . . on such functions.
Q22
What is the order of Destructors call when the object of derived class B is declared, provided class B is derived from class A?
Q23
What is the role of a virtual destructor in C++?
Q24
In C++, can a derived class have its own definition of a function that is already defined in the base class?
Q25
What is function overloading in C++?