logo

CuriousTab

CuriousTab

Inheritance problems


  • 1. In an inheritance chain which of the following members of base class are accessible to the derived class members?

    1. static
    2. protected
    3. private
    4. shared
    5. public

  • Options
  • A. 1, 3
  • B. 2, 5
  • C. 3, 4
  • D. 4, 5
  • Discuss
  • 2. Which of the following statements are correct about Inheritance in C#.NET?

    1. A derived class object contains all the base class data.
    2. Inheritance cannot suppress the base class functionality.
    3. A derived class may not be able to access all the base class data.
    4. Inheritance cannot extend the base class functionality.
    5. In inheritance chain construction of object happens from base towards derived.

  • Options
  • A. 1, 2, 4
  • B. 2, 4, 5
  • C. 1, 3, 5
  • D. 2, 4
  • Discuss
  • 3. Assume class B is inherited from class A. Which of the following statements is correct about construction of an object of class B?

  • Options
  • A. While creating the object firstly the constructor of class B will be called followed by constructor of class A.
  • B. While creating the object firstly the constructor of class A will be called followed by constructor of class B.
  • C. The constructor of only class B will be called.
  • D. The constructor of only class A will be called.
  • E. The order of calling constructors depends upon whether constructors in class A and class B are private or public.
  • Discuss
  • 4. Which of the following can be facilitated by the Inheritance mechanism?

    1. Use the existing functionality of base class.
    2. Overrride the existing functionality of base class.
    3. Implement new functionality in the derived class.
    4. Implement polymorphic behaviour.
    5. Implement containership.

  • Options
  • A. 1, 2, 3
  • B. 3, 4
  • C. 2, 4, 5
  • D. 3, 5
  • Discuss
  • 5. Which of the following is correct about the C#.NET snippet given below?

    namespace CuriousTabConsoleApplication
    { 
        class Baseclass
        { 
            public void fun()
            { 
                Console.WriteLine("Hi" + " ");
            } 
            public void fun(int i)
            {
                Console.Write("Hello" + " ");
            } 
        } 
        class Derived: Baseclass
        {
            public void fun()
            {
                Console.Write("Bye" + " ");
            } 
        } 
        class MyProgram
        { 
            static void Main(string[ ] args)
            { 
                Derived d; 
                d = new Derived(); 
                d.fun(); 
                d.fun(77);
            } 
        } 
    }

  • Options
  • A. The program gives the output as: Hi Hello Bye
  • B. The program gives the output as: Bye Hello
  • C. The program gives the output as: Hi Bye Hello
  • D. Error in the program
  • Discuss
  • 6. If a base class and a derived class each include a member function with the same name, the member function of the derived class will be called by an object of the derived class

  • Options
  • A. True
  • B. False
  • Discuss
  • 7. Private members of base class cannot be accessed by derived class member functions or objects of derived class.

  • Options
  • A. True
  • B. False
  • Discuss
  • 8. There is no multiple inheritance in C#.NET. That is, a class cannot be derived from multiple base classes.

  • Options
  • A. True
  • B. False
  • Discuss
  • 9. The size of a derived class object is equal to the sum of sizes of data members in base class and the derived class.

  • Options
  • A. True
  • B. False
  • Discuss
  • 10. Multiple inheritance is different from multiple levels of inheritance.

  • Options
  • A. True
  • B. False
  • Discuss

First 2 3