C++ Programming Test

    Welcome to your C++ Programming Test

    1. What will be the output of following code ? #include using namespace std; void fun() { static int i = 10; i++; cout << i; } int main() { fun(); fun(); fun(); return 0; }
    2. You can never use or compute address of _________ variable ?
    3. What will be the output of following code ? #include using namespace std; void calc(int x); int main() { int x = 10; calc(x); printf("%d", x); return 0; } void calc(int x) { x = x + 10 ; }
    4. Default storage class for local variables is ?
    5. __________ is defined as user defined data type and it also contains functions in it ?
    6. For below code snippet, the public and protected members of Superclass becomes _________ members of Sub class. class subclass : protected Superclass
    7. What will be the output of following code ? #include using namespace std; class Animal { public: int legs = 4; }; class Dog : public Animal { public: int tail = 1; }; int main() { Dog d; cout << d.legs; cout << d.tail; }
    8. Do base class and its object have any knowledge about any classes derived from base class?
    9. What is Multiple Inheritance ?
    10. Whenever you create derived class object, first the base class default constructor is executed and then the derived class constructor?
    11. Which of the following Function is not inherited?
    12. What will be the output of following code? #include using namespace std; class Base { public: Base() { cout << "Base"; } }; class Derived : public Base { public: Derived(int i) { cout << i; } }; int main() { Derived d2(10); return 0; }
    13. What will be the output of following code? #include using namespace std; class A { int x; }; class B : public A { public: void show() { x=10; cout << x; } }; int main() { B b; b.show(); return 0; }
    14. Which symbol is used to create multiple inheritance ?
    15. All members of a Base class including private member are inherited in Derived class.