Inheritance is the process by which one object acquires the properties of another object. This is important because it supports the concept of hierarchical classification.
Hierarchical classification is how we classify various types of objects. Animal kingdom is one good hierarchical classification where animals are classified into Protozoa and Metazoa, and how Metazoa is classified into Invertebrates and Vertebrates, how Vertebrates are further classified into Reptiles, Birds and Mammals and how Mammals are classified into Dogs, Cats and Humans. In other words, every Human is a Mammal, every Mammal is a Vertebrate and every Vertebrate is a Metazoa. But note that every Mammal need not be Human and every Vetebrate need not be a Mammal.
Similarly Electronics can be classified into Radios, Televisions, Kitchen Appliances, Personal Appliances and how Personal Appliances can be classified into Computers and Mobiles and how Computers can be further classified into Laptops, Desktops and Tablets. Here every Laptop is a Computer, which is a Personal Appliance, which is an Electronic Device. Where as every Electronic Device need not be a Personal Appliance, every Personal Appliance need not be a Computer and every Computer need not be a Desktop or Laptop.
Similarly, the classes in Java are also classified and inherited according to the usage. As seen in the Entertainment's example in Java Class Inheritance, we have inherited the properties (data and behavior) (variables and methods) from the super-class
In the Inheritance Example Program To Remove Duplicate Code program we have the super-class
We have seen in the above mentioned programs, how inheritance helps in making complex programs simpler and how it helps in removing duplicate code which in turn makes maintenance and enhancements easy.
Dependent Topics : Abstraction in Java