CISCE ISC (Science) ISC Class 12 Important Questions for Computer Science (Theory) - Inheritance, Interfaces and Polymorphism
Advertisements
Advertisements
Chapter wise important questions with answers and solutions for Computer Science (Theory) in CISCE ISC (Science) ISC Class 12.
The ability of an object to take many forms is known as ______.
Chapter: [12] Inheritance, Interfaces and Polymorphism
A super class Godown has been defined to store the details of the stock of a retail store. Define a subclass Update to store the details of the items purchased with the new rate and update the stock. Some of the members of both the classes are given below:
| Class name | Godown |
| Data members/instance variables: | |
| item | to store the name of the item |
| qty | to store the quantity of an item in stock |
| rate | to store the unit price of an item |
| amt | to store the net value of the item in stock |
| Member functions/methods: | |
| Godown(…) | parameterized constructor to assign value to the data members |
| void display( ) | to display the stock details |
| Class name | Update |
| Data members/instance variables: | |
| pur_qty | to store the purchase quantity |
| pur_rate | to store the unit price of the purchased item |
| Member functions/methods: | |
| Update(…) | parameterized constructor to assign values to the data members of both the classes |
| void update( ) | to update the stock by adding the previous quantity by the purchased quantity and replace the rate of the item if there is a difference in the purchase rate. Also update the current stock value as: (quantity * unit price) |
| void display( ) | to display the stock details before and after updating |
Assume that the super class Godown has been defined. Using the concept of inheritance, specify the class Update giving details of the constructor, void update ( ) and void display( ).
The super class, main function and algorithm need NOT be written.
Chapter: [12] Inheritance, Interfaces and Polymorphism
A super class EmpSal has been defined to store the details of an employee. Defie a subclass (overtime to compute the total salary of the employee, after adding the overtime amount based on the following criteria.
- If hours are more than 40, then 5000 are added to salary as an overtime amount
- If hours are between 30 and 40 (both inclusive), then 3000 are added to salary as an overtime amount
- If hours are less than 30, then the salary remains unchanged The details of the members of both the classes are given below:
| Class name | EmpSal |
| Data members/instance variables: | |
| empnum | to store the name of the employee |
| empcode | integer to store the employee code |
| salary | to store the salary of the employee in decimal |
| Methods/Member functions: | |
| EmpSal(...) | parameterised constructor to assign values to data members |
| void show() | to display the details of the employee |
| Class name | Overtime |
| Data members/instance variables: | |
| hours | integer to store overtime in hours |
| totsal | to store the total salary in decimal |
| Methods/Member functions: | |
| Overtime(....) | parameterised constructor to assign values to data members of both the classes |
| void calSal() | calculates the total salary by adding the overtime amount to salary as per the criteria given above |
| void show() | to display the employee details along with the total salary (salary +overtime amount) |
Assume that the super class EmpSal has been defined. Using the concept of inheritance, specify the class Overtime giving the details of the constructer (...), void calSal() and void show().
The super class, main function and algorithm need NOT be written.
