New ! Computer Science MCQ Practise Tests



Inheritance Three Marks Questions

11th Standard

    Reg.No. :
  •  
  •  
  •  
  •  
  •  
  •  

Computer Science

Time : 00:45:00 Hrs
Total Marks : 30
    10 x 3 = 30
  1. What are the points to be noted while deriving a new class?

  2. What do you mean by overriding?

  3. Why do you need for inheritance?

  4. Explain the uses of private, protected and public inheritance.

  5. In what situation shadowing base class function inderived class arises? How will you resolve the situation?

  6. Write the output of the following program.
    //Implementation of Single Inheritance using public
    visibility mode
    #include < iostream >
    using namespace std;
    class Shape
    {
    private:
      int count;
    protected:
      int width;
      int height;
    public:
      void setWidth(int w)
      {
      width=w;
      }
    void setHeight(int h)
    {
    height=h;
    }
    };
    class Rectangle: publicShape
    {
    public:
    int getArea()
    {
    return (width * height);
    }
    };
    int main()
    {
    Rectangle Rect;
    Rect.setWidth( 5);
    Rect.setHeight(7);
    II Print the area of theobject.
    cour<< "Total area: "<< Rect.getArea() << endl;
    return ();
    }

  7. Write the output of the following program.
    #include< iostream >
    using namespace std;
    class T
    {
      public:
    int x;
      void foot()
    {
      x = 6; // same as this->x = 6;
      this ->x = 5; // explicit use of this ->
    cout<x;
    }
      void foo(int x) // parameter x shadows the member
      with the same name
    {
      this->x = x; // unqualified x refers to the
      parameter.'this->' required for disambiguation
      cout<< endl << x <<" "<x;
    }};
    int main()
    {
    T t1,t2;
    t1.foot();
    t2.food();
    }

  8. Can a derived class get access privilege for a private member of the base class? If yes, how?

  9. What is inheritance and access control?

  10. Write the derived class using any of the three visibility mode.

*****************************************

Reviews & Comments about 11th Computer Science - Inheritance Three Marks Questions

Write your Comment