0
654views
Inheritance vs Polymorphism.

Differentiate between Inheritance and Polymorphism.

1 Answer
5
9views
BASIS FOR COMPARISON INHERITANCE POLYMORPHISM
BASIC Inheritance is creating a new
class using the properties of 
the already existing class.
Polymorphism is basically
a common interface
for multiple form.
IMPLEMENTATION It is implemented on classes. It is basically implemented
on functions/methods.
USE To support the concept of
reusability in OOP and reduces
the length of code.
Allows object to decide 
which form of the function
to be invoked when,at
compile time as well
as run time.
FORMS It may be a single inheritance,
multiple inheritance,multilevel
inheritance,hiearchical inheritance
and hybrid inheritance.
It may be a compile time 
polymorphism or run-time
polymorphism.
EXAMPLE The class 'table' can inherit the feature
of the class 'furniture',as a 'table' is
a 'furniture'.
The class 'study-table' can also 
have function 'set_color()' and a
class 'Dining_table' can also
have function 'set_color()' so,
which form of the set_color()
function to invoke can be
decided at both compile time,
and run time.
Please log in to add an answer.