New ! Computer Science MCQ Practise Tests



11th Standard English Medium Computer Science Subject Inheritance Creative 5 Mark Questions with Solution Part - I

11th Standard

    Reg.No. :
  •  
  •  
  •  
  •  
  •  
  •  

Computer Science

Time : 01:00:00 Hrs
Total Marks : 25

    5 Marks

    5 x 5 = 25
  1. 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;
    }

  2. 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;
    }

  3. 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);

  4. Given the following set of definitions:
    class x { :
    };
    class y : public x
    {;
    };
    class z : public y
    {;
    };
    (i) What order will the constructors and destructor's be invoked in?

  5. Answer the questions (i) to (iv) based on the
    following code :
    class Teacher
    { char TNo[5], TName [20], Dept[10];
    int Workload;
    protected:
    float Salary ;
    void AssignSal (float) ;
    public:
    Teacher ( );
    void TEntry ( ) ;
    void TDisplay ( ) ;
    };
    class student
    {
    char Admno[10], SName [20], Stream [10];
    protected:
    intAttendance, TotMarks;
    public:
    Student ( );
    void SEntry ( ) ;
    void SDisplay ( ) ;
    };
    class School: public Student, public Teacher
    {
    char SCode [10], SchName [20] ;
    public:
    School ();
    void SchEntry ( ) ;
    void Schfrisplay ( ) ; };
    (i) Which type of Inheritance is depicted by the above example?
    (ii) Identify the member function(s) that cannot be called directly from the objects of class School from the following:
    TEntry ()
    SDisplay( )
    SchEntry( )
    (iii) Write name of all the member(s) accessible from member functions of class School.
    (iv) If class School was derived privately from class Teacher and privately from class Student; then, name the member function(s) that could be accessed through objects of class school.

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

Reviews & Comments about 11th Standard English Medium Computer Science Subject Inheritance Creative 5 Mark Questions with Solution Part - I

Write your Comment