question a explain the concept of polymorphism


Question :

(a) Explain the concept of polymorphism when used in programs using suitable examples of your own.

(b) (i) Distinguish between abstract methods and non-abstract methods.

(ii) Explain how and when abstract methods are used in programs.

(c) Write down the interface 'PowerSource' to contain the following:-
(i) method 'computePower' of type double
(ii) String method 'type'

(d) Write down the class 'ElectricitySource' which inherits from the superclass

'Object' and the interface 'PowerSource' and contains the following:-

(i) integer variable 'electricity_source_id'

(ii) String variable 'name'

(iii) variable 'amount_available' of data type double

(iv) set methods for each of the variables

(v) get methods for each of the data members

(vi) override the two methods inherited from the interface 'PowerSource'
(e) Write down a driver program to perform the following operations:-
(i) create one 'ElectricitySource' object
(ii) assign values to the data members
(iii) output all the values

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: question a explain the concept of polymorphism
Reference No:- TGS0373935

Expected delivery within 24 Hours