New ! Computer Science MCQ Practise Tests



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

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

  2. Consider the following and answer the questions given below:
    class MNC
    {
    char Cname[25] ; //Company name
    protected:
    char Hoffice[25]; // Head office
    public:
    MNC( ) ;
    char Country [25];
    void EnterData ( ) ;
    void DisplayData ( ) ;
    };
    class Branch: public MNC
    }
    long NOE [Number of employees
    \\country char Ctry [25];
    protected:
    void Association ( ) ;
    public:
    Branch ( ) ;
    void add  ( ) ;
    void Show ( ) ;
    };
    class Outlet: public Branch
    char State [25];
    public:
    Outlet ( ) ;
    void Enter ( ) ;
    void Output ( ) ;
    };
    (i) Which class constructor will be called first at the time of decla~ation of an object Outlet?
    (ii) How many types of on object belonging to class output require?
    (iii) Name the number functional which are accessed from the objects of class Outlet.
    (iv) Name the data numerical, which are accessible from the object(s) of class Outlet.

  3. Answer the questions (i) to (iv) on the following
    code:
    class Dolls
    {
    char DCode[5];
    protected :
    float Price;
    void CalcPrice (float);
    public:
    Dolls ();
    void DInput ( ) ;
    void DShow ( ); .
    };
    class SoftDolls : public Dolls
    }
    char SDName[20];
    float Weight;
    public:
    SoftDolls ( ) ;
    void SDInput ( ) ;
    void SDShow ( ) ;
    };
    class ElectronicDolls : public Dolls
    }
    char EDName [20];
    char BatteryType[10];
    int Batteries ;
    public: .
    Electronic Dolls ( );
    void EDInput ( ) ;
    void EDShow ( ) ;
    };
    (i) Which type of Inheritance is shown in the above example?
    (ii) How many bytes will be rreqiured by an object of the class ElectronicDolls?
    (iii) Write name of all the data memebrs accessible from member functions of the class softDolls.
    (iv) Write name of all the member functions accessible by· an object of the class ElectronicDolls.

  4. A railway reservation counter needs to computerise its reservation process. Using the following information write a C ++ program to do so:
    class Train {
    int number; //Train number
    int seats _1; //Total seats in 1st class
    int seats _2 ; //Total seats in 2nd class
    int seats _3; //Total seats in 3rd class
    public;
    Train (int i, int j, int k, int l)
    {
    number = i; seats_1 =j ;
    seats-2 =' k;,seats-3 = 1,.
    }
    int getnum(void)
    { return number; }
    int getseats_1(void)
    { return seats_1 ; }
    int getseats_2(void)
    { return seats _2 ;}
    int getseats - 3 (void)
    {return seats - 3:}
    };
    class Reservation : public Train
    { int bkd_1 ; //Seats reserved in 1st class
    int bkd_2 ; ///Seats reserved in 2nd class
    int bkd_3 ; ///Seats reserved in 3rd class
    public:
    int i, j, k, 1;
    Reservation (int i, int j, int k, int 1) : Train (i ,j, k,l)
    {bkd_1 = bkd_2 = bkd_3 = 0 ; }
    void book(char type, int num);
    void cancel (char type, int num) ;
    void disp_status (void);
    };
    void Reservation: : book (char type, int num)
    { switch(type)
    }
    case '1': bkd_1+=num; //addnum to bkd_1
    break;
    case '2': bkd_2+=num; //addnum to bkd_2
    break ;
    case '3': bkd_3+=num; Iladdnum to bkd_3
    break;
    default: cout <<"Wrong class\n";
    }
    }
    void Reservation: : cancel (char type. int num)
    { switch(type)
    }
    case '1': bkd_1-=num;
    break;
    case '2': bkd_2-=num;
    break ;
    case '3' : bkd_3-=num;
    break ;
    default: cout <<"Wrong class\n" ;
    }
    }
    void Reservation : : disp_stauts (void)
    {
    cout <<"\t\t Train Numbe r: "< cout <<"Class\t Total seats\t Reserved \t
    Unreserved\n" ;
    int val;
    val = getseats_1 () ;
    cout<< "I\t "< xval << "\t "<< bkd_1<< "
    \t "<< val-bkd_1 << "\n";​​​​​​​
    val = getseats_2 () ;
    cout << "2\t "<< val << "\t "< xbkd 2 << "​​​​​​​​​​​​​​
    \t "<< val-bkd_2 << "\n";​​​​​​​
    val = getseats_3 ( ) ;​​​​​​​
    cout << "3\t "<< val << "\t "<< bkd 3 << "​​​​​​​
    \t "<< val-bkd_3 << "\n";​​​​​​​

  5. (a) Define Multilevel and Multiple inheritance in context of object Oriented Programming Code suitable example to illustrate the same.
    (b) Answer the questions (i) to (iii) based on the following code:
    class stationery
    {
    char Type ;
    char manufacturer [10] ;
    public:
    stationery ( );
    void Read_Sta_details ();
    void Disp_sta_details( ) ;
    };
    class office: public stationery
    }
    int no_of types;
    float cost_of_sta ;
    public:
    void Read_off_details( );
    void Disp_off details( ) ;
    };
    class printer: private office
    {
    int no_of users ;
    char delivary_date[10];
    public:
    void Read_pri _details( );
    void Disp_pri _details( ) ;
    };
    voidmain()
    { printer Myprinter ;
    }
    (i) Mention the member names which are accessible by MyPrinter declared in main( ) function.
    (ii) What is the size of Myprinter in bytes?
    (iii) Mention the names of functions accessible from the member function Read yri-details ( ) of class printer.

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

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

Write your Comment