Page 22 - CA_Blue( J )_Class9
P. 22

Let’s understand with another example: a 'Car' inherits its properties from the class 'Motor Driven' which inherits
                  some of its properties from another class 'Vehicle'.













                  Concept of Reusability                                                 Definition
                  While developing a code, there may be a requirement to create
                  more than one class. Under such situation, we may share the   Inheritance in Java is the method that allows one
                  data members and methods of one class with another class.   class to inherit the properties (data members
                  This helps to reduce the lines of code as well as the complexity   and member methods) of another class.
                  of the programs. This is the concept of reusability.

                  Essential terms related to Inheritance
                  Class from where features are inherited to another class. It is also
                  known as base class or parent class.
                  Class which inherits the features of another class is called derived
                  class or extended class or child class. Apart from features of Base
                  Class, it may have its own features (data members and methods).
                  For example, “Vertebrate” is superclass and “Fish” and “Mammal”
                  are subclass as both Fishes and Mammals have backbones which
                  are the properties of the superclass Vertebrate.


                  1.3.5 Polymorphism
                  The word Polymorphism is derived from the Greek word meaning “many forms” ("poly" means many and "morphe"
                  means form). In object-oriented programming (OOP), polymorphism is a feature that allows objects to exhibit
                  multiple forms or behaviours, depending on the context in which they are used.

                  For example, a Car object might represent different types of cars: a family car, a taxi, or a pool car used by students
                  of a school. Each type of car could share the same general structure but behave differently depending on its
                  specific type or purpose.

                  In  object-oriented programming, polymorphism
                  is the  feature  of being able to assign a different
                  meaning  so  that a variable, a method,  or an
                  object can have  more  than  one form. Thus, it is
                  the capability  of altering the  characteristics and
                  behaviour of a variable and use it in many forms
                  according to the need of an object. Polymorphism
                  allows the  program  to automatically select  and
                  apply the appropriate methods to an object based
                  on  the subclass  to  which  it  belongs,  enabling
                  the same  code to handle  various  object types
                  seamlessly.



                    20    Touchpad Computer Applications-IX
   17   18   19   20   21   22   23   24   25   26   27