Page 13 - JAVA Programming
P. 13

12




               Abstraction


                     Abstraction  is  the  concept  of  object-oriented  programming  that
                       "shows"  only  essential  attributes  and  "hides"  unnecessary
                       information.  The  main  purpose  of  abstraction  is  hiding  the
                       unnecessary details from the users. Abstraction is selecting data from
                       a larger pool to show only relevant details of the object to the user. It
                       helps in reducing programming complexity and efforts. It is one of the
                       most important concepts of OOPs.

               Encapsulation


                     Encapsulation in Java is a mechanism to wrap up variables(data) and
                       methods(code)  together  as a  single unit. It  is the process of  hiding
                       information details and protecting data and behaviour of the object. It
                       is one of the four important OOP concepts. The encapsulate class is
                       easy to test, so it is also better for unit testing.

               Inheritance


                     Inheritance is a mechanism in which one class acquires the property
                       of  another  class.  For  example,  a  child  inherits  the  traits  of  his/her
                       parents. With inheritance, we can reuse the fields and methods of the
                       existing  class.  Hence,  inheritance  facilitates  Reusability  and  is  an
                       important concept of OOPs.

               Types of Inheritance: -

               Single Inheritance: In Single Inheritance one class extends another class
               (one class only).

               Multiple  Inheritance:  In  Multiple  Inheritance, one  class extending more
               than one class. Java does not support multiple inheritance.

               Multilevel Inheritance: In Multilevel Inheritance, one class can inherit from
               a derived class. Hence, the derived class becomes the base class for the new
               class.

               Hierarchical Inheritance: In Hierarchical Inheritance, one class is inherited
               by many sub classes.
               Hierarchical Inheritance

               Hybrid  Inheritance:  Hybrid  inheritance  is  a  combination  of  Single  and
               Multiple inheritance.
   8   9   10   11   12   13   14   15   16   17   18