Page 448 - Computer science 868 Class 12
P. 448

12                    INHERITANCE, INTERFACES



                                                                        AND POLYMORPHISM
















                          Learning Objectives


                      12.1  Inheritance, Base and Derived Class           12.2  Solved Programs on Inheritance
                      12.3  Function Overloading and Polymorphism         12.4  Keyword Abstract
                      12.5  Interface in Java





                Merriam  Webster  defines inheritance  as “the acquisition of a possession,           Parents
                condition,  or trait  from past generations”.  In  simple  words, when the older
                generation passes its property and valuable possessions to its next generation,
                then the later is said to inherit the valuables from his/her family by virtue of his/
                her birth right.

                Object-oriented  programming concepts are  inspired from the  real world.
                Inheritance is an important feature of OOP. Let us understand the concept in
                detail.                                                                  Inheritance             Parents Property

                    12.1 INHERITANCE, BASE AND DERIVED CLASS

                Inheritance  allows objects of one class to acquire  or access  variables and          Child
                methods of other classes, thereby establishing class hierarchies. We, thus, conclude implementation of inheritance
                involves at least two classes.  They are as follows:
                •  Base class or Super class: The class that shares its variables and methods with another class is called Base class or
                   Super class.
                •  Subclass or Derived class: The class that inherits the properties (member data and methods) from the base class
                   is called Subclass or Derived class. The subclass can add its own variables and methods in addition to the super
                   class properties it has inherited.


                                                               Definition

                      Inheritance can be defined as an OOP paradigm where the derived class acquires the characteristics of the base
                      class.





                446446  Touchpad Computer Science-XII
   443   444   445   446   447   448   449   450   451   452   453