Page 475 - Computer science 868 Class 12
P. 475
5. ………………… in Java refers to the same object having multiple forms and attributes.
6. ………………… methods are the methods with no method body.
Answers
1. transitive 2. interface 3. public 4. hybrid 5. Polymorphism 6. abstract
C. Answer the following questions:
1. Differentiate between method overloading and method overriding.
Ans.
Method overloading Method overriding
a. Methods have the same names but different signatures. a. Methods have the same names and same signature.
b. It can be implemented in same class or derived class. b. Overriding methods belong to the base and derived
classes.
c. Function call and function signature are linked at compile c. Function call and function signature are linked at run
time. time.
2. Differentiate between interface and abstract class.
Ans.
Interface Abstract class
a. It has abstract methods only. a. It has both abstract and concrete methods.
b. A class can implement multiple interface. b. A class can inherit only a single abstract class.
c. Interface variables are declared as public static final. c. Abstract class variables can contain any access modifiers.
3. Differentiate between the keywords extends and implements.
Ans.
Extends Implements
a. The extends keyword is used to inherit a class. a. The implements keyword is used to define interface.
b. A class can extend only a single class. b. A class can implement multiple interfaces.
c. A subclass that extends a super class can override some c. A class must implement all the methods from interfaces.
of it’s methods.
4. 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. [ISC Specimen Paper 2022 Semester II]
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( …) : parameterised constructor to assign values 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(…) : parameterised constructor to assign values to the data members of
both the classes
473
Inheritance, Interfaces and Polymorphism 473

