Topics Index

Object Oriented Concepts - Revisited >
Siva Nookala - 14 Apr 2016
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 Entertainment into the sub-classes Movie, Drama and Circus.
In the Inheritance Example Program To Remove Duplicate Code program we have the super-class IceCream and its sub-classes FruitSaladWithIceCream and KhubaniKaMeetaWithIceCream. In the Vehicles Hierarchy program in Multilevel Inheritance In Java With Example Program, we have seen the MountainBike inheriting the properties from Bike, which inturn inherits from RegisteredVehicle, which in turn inherits from Vehicle.

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 

Score more than 2 points

© meritcampus 2016 - 2017

All Rights Reserved.