New ! Computer Science MCQ Practise Tests



Inheritance Model Question Paper

11th Standard

    Reg.No. :
  •  
  •  
  •  
  •  
  •  
  •  

Computer Science

Time : 01:00:00 Hrs
Total Marks : 50
    5 x 1 = 5
  1. Which of the following class is a power packed class?

    (a)

    sub class

    (b)

    child class

    (c)

    derived class

    (d)

    all of these

  2. Which of the following statement is true or false?
    (i) Inheritance represents read world relationships
    (ii) Inheritance does not provide code resuability
    (iii) Inheritance does not supports transitivity
    (iv) Inheritance support private visibility mode

    (a)

    (i) false, (ii) false, (iii) true, (iv) false

    (b)

    (i) true, (ii) false, (iii) false, (iv) true

    (c)

    (i) true, (ii) false, (iii) false, (iv) true

    (d)

    (i) false, (ii) true, (iii) true, (iv) false

  3. When more than one derived clauses are created from a single base class called ________.

    (a)

    Multiple

    (b)

    Multilevel

    (c)

    Hybrid

    (d)

    Hierarchical

  4. When a derived class inherits from multiple base classes is known as ________.

    (a)

    Multilevel

    (b)

    Multiple

    (c)

    Hierarchical

    (d)

    Hybrid

  5. The default visibility mode is ________.

    (a)

    public

    (b)

    private

    (c)

    protected

    (d)

    class

  6. 5 x 2 = 10
  7. List the types of inheritance.

  8. How many bytes will occupy by the class without any declaration?

  9. Differentiate containership and Inheritance?

  10. Write a short note on hierarchical inheritance.

  11. Define protected visibility mode.

  12. 5 x 3 = 15
  13. Why do you need for inheritance?

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

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

  16. What is inheritance and access control?

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

  18. 4 x 5 = 20
  19. Write the output of the. following program.
    #include< iostream >
    using namespace std;
    class base
    {
    public:
    base( )
    {
    cout<<"\nConstructor of base class ...";
    }
    ~base( )
    {
    cout << "\nDestructor of base class .... ";
    }
    } ;
    class derived:public base
    {
    public:
    derived()
    {
    cout << "\nConstructor of derived ...";
    }
    ~derived( )
    {
    cout << "\nDestructor of derived ...";
    }
    };
    class derived 1 :public derived
    {
    public:
    derived1( )
    {
    cout << "n\nConstructor of derivedl ...";
    }
    ~derived 10
    {
    cout << "\nDestructor of derivedl ...";
    }
    };
    int main ()
    {
    derived 1 x;
    return 0;
    }

  20. Write the output of the following program based on the information given below.
    The student Raguram studying in class XII and his roll number is 11201 and the date of birth is 14/01/2002. and he scored 100 marks in all the subjects

    # include < iostrearn >
    using namespace std;
    class student //base class
    {
    private:
    char name[20];
    intmo;
    public:
    void acceptname( )
    {
    cout<< "\n Enter roll no and name ...";
    cin >> rno >> name;
    }
    void displayname()
    {
    cout<< "\n Roll no :-"< cout<< "\n Name :-"< } };
    class exam : public student
    //iderived class with single base class
    {
    public:
    int mark1, mark2 ,mark3,mark4,mark5,mark6;
    void acceptmark( )
    {
    cout << "\n Enter lang,eng,phy,che,csc,mat marks .. ";
    cin >> mark1 >>mark2 >> mark3 >> mark4 >> mark5 >> mark6;
    }
    void displaymark() {
    cout<< "\n\t\t Marks Obtained ";
    cout<< "\n Language .. "< cout<< "\n English .. "< cout<< "\n Physics .. "< cout<< "\n Chemistry .. "< cout<< "\n Comp.sci .. "< cout<< "\n Maths .. "< }
    };
    class detail //base classs 2
    {
    int dd,mm,yy;
      char cl[4];
    public:
      void acceptdob()
    {
    cout<< "\n Enter date,month,year in digits and class .. ";
    cin >> dd >> mm >> yy >> cl;
    }
    void displaydob()
    {
    cout << ''n class :-"< cout << "\t\tDOB :,"< }
    };
    class result: public exam,public detail
    //inherits from exam ,which itself is a
    //derived class and also from class detail
    {
    int total;
    public:
      void showresult( )
    {
    total=mark1 +mark2+mark3+mark4+mark5+mark6;
    cout<<"\nTOTAL MARK SCORED: "<  }
    };
    class detail //base classs 2
    {
    int dd,mm,yy;
    char cl[4];
    public:
    void acceptdob()
    {
    cout << "\n Enter date,month,year in digits and class .. ";
    cin >> dd >> mm >> yy >> cl;
    }
    void displaydob( )
    {
    cout << "\n class :-"< cout << ''\t\tDOB: "< }
    };
    class result: public exam,public detail
    //inherits from exam ,which itself is a
    //derived class and also from class detail
    {
     int total;
     public:
       void showresult( )
    {
      total=mark1 +mark2+mark3+mark4+mark5+mark6;
      cout << "\nTOTAL MARK SCORED
      "<  }
    };
    int main( )
    {
    result r1;
    r1.acceptname( );
    //calling base class function using derived class
    object
    r1.acceptmark ( );
    //calling base class which itsel is a derived class
    function using its derived class object
    int main( )
    {
    result r1;
    r1.acceptname ( );
    //calling base class function using derived class
    object
    rlacceptmark( );
    //calling base class which itsel is a derived class
    function using its derived class object
    r1.acceptdob ( );
    cout << "\n\n\t\t MARKS STATEMENT";
    r1.displayname ( );
    //calling base class function using derived class
    object
    r1. Ldisplaydob( );
    r1.displaymark( );
    //calling base class which itsel is a derived class
    function using its derived class object
    r1.showresult( ); //calling the child class function
    return 0;
    }

  21. Write the output of the following program.
    # include < iostream >
    class person

    Public:
    string profession;
    int age;
    Person() Profession ("unemployed"),
    age (16) {}
    void display ( )
    {
    cout-<<"My profession is:
    "< cout-<< "My age is: "<< age< walk ();
    talk ();
    }
    void walk()
    { cout-<< "I can walk" < }
    void talk ()
    {cout-<< "I can talk" < }
    };
    Class Teacher: Public Person
    {
    Public:
    void teachrnaths ( )
      {cout-<< "I can teach Maths" <   }
    };
    Class Player: Public Person
    {
      Public:
      void play football ( )
    { cout-<< "I can play football" < }
    int main ()
    {
    Teacher t1;
    t1.profession = "Teacher"
    t1. age = 24 ;
    t1. display ( ) ;
    t1. teachmaths( );
    Player f1;
    f1. profession -= "footballer"
    f1. age = 21
    f1. display ( ) ;
    f1. play football ( ) ;
    return 0;
    }

  22. Given the following set of definitions. What data
    members and functions are directly accessible by
    the functions mentioned here?
    void inform(void):
    class x {
    int a;
    float b,
    void init(void);
    public:
    char ch; void gett(void)
    protected:
    doublet;
    void get amt (void) ;
    friend void A (void);
    };
    class y: public X
    {
    intx;
    public;
    intj;
    void readit(void) ;
    protected :
    void inform (void);
    friend void B (void);
    };
    void display (void);

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

Reviews & Comments about 11th Computer Science - Inheritance Model Question Paper

Write your Comment