|
By Nishant Kumar
Define Inheritance.
Inheritance concept in OOP allows us to create a new class using an existing
one. It also allows the new class to add its own functionality. This concept
can also be related to real world entity. A bike manufacturer uses same
mechanism of existing version of the bike while launching a new version with
some added functionalities. This allows him to save time and efforts.
|
Explain the term Polymorphism.
Polymorphism means the ability to take more than one form. An operation may
exhibit different behaviors in different instances. The behavior depends on the
data types used in the operation.
What is Overloading Polymorphism?
Overloading allows multiple functions to exist with same name but different
parameters. Again if you take bike as an example, it has a function “Start”
with two forms i.e. 'Auto Start' and 'kick start'.
Explain Overriding Polymorphism.
Overriding means changing behavior of methods of base class in derive class by
overriding the base class methods. If class A is a base class with method
'calculate' and class B inherits class A, thus derives method 'calculate' of
class A. The behavior of 'calculate' in class B can be changed by overriding
it.
|