Page 287 - CA_Blue( J )_Class10
P. 287

Unsolved Questions



                 A.  Tick ( ) the correct answer.
                    1.  Which keyword is used to create an instance of a class in many object oriented languages?
                       a.  def                                         b.  class
                       c.  new                                         d.  create
                    2.  Which of the following is NOT a feature of object oriented programming?
                       a.  Encapsulation                               b.  Polymorphism
                       c.  Abstraction                                 d.  Compilation
                    3.  What does polymorphism allow in object oriented programming?
                       a.  Multiple classes to inherit from one class   b.  Methods to operate on different types of objects
                       c.  A class to have more than one instance      d.  Data hiding from external classes
                    4.  Which of the following best describes a constructor in a class?
                       a.  A method for destroying objects
                       b.  A method for creating and initializing objects
                       c.  A method that can be called multiple times
                       d.  A method that prevents inheritance
                    5.  What is abstraction in the context of object oriented programming?
                       a.  The ability of different classes to be treated as instances of the same class through inheritance
                       b.  Hiding the complex implementation details and showing only the necessary features
                       c.  The practice of using pointers to access memory
                       d.  The process of converting one type of object into another

                 B.  Answer the following questions:
                    1.  Create a class Employee and basic as its data member, to find the gross pay of an employee for the following allowances and
                       deductions.
                       class name : Employee
                       Data members
                       String name         :  name of the Employee
                       double basic        :  basic salary of the Employee
                       double da           :  dearness allowance of the Employee
                       double hra          :   House Rent Allowance of the Employee
                       double pf           :  Provident Fund of the Employee
                       double np           :   Net pay of the Employee
                       double gp           :   Gross pay of the Employee
                       Member Methods
                       void input()        :   Accepts the name and basic salary
                       void cal()          :   Calculates the following
                       Dearness Allowance   =   25% of the Basic Pay
                       House Rent Allowance   =   15% of Basic Pay
                       Provident Fund      =  8.33% of Basic Pay
                       Net Pay             =    Basic Pay + Dearness Allowance + House Rent Allowance
                       Gross Pay           =   Net Pay − Provident Fund
                       void display()      :  Prints all the Data members.
                    2.  Define a class ‘tax’ described as below:
                       class name          :   tax
                       Data Members
                        Name, Department, Monthly Salary, Income Tax.
                       Member Methods
                       i.  To accept the details of a teacher including the monthly salary.
                       ii.  To compute the annual Income Tax as 12% of the annual salary above Rs.2,00,000/-.
                       iii. To display the details of the teacher.
                        Write a main method to create object of the class and call the above member methods.


                                                                                                                       285
                                                                                      Class as the Basis of all Computation  285
   282   283   284   285   286   287   288   289   290   291   292