What Is Inheritance?
by, 04-26-2012 at 06:28 PM (857 Views)
Various objects consist of certain common amount with each other. Tandem bikes, mountain bikes and road bikes etc share the common bicycle characteristics (current gear, current speed, and current pedal cadence). Yet, additional features are defined byeach which will make them a bit different: Road cycles consist of handlebars; tandem bicycles consist of 2 handlebar sets & 2 seats; mountain bikes have an extra chain ring that provides low gear ratio to them.
Object oriented programming inherits the commonly used behavior and state from various other classes. Now, Bicycle has become, in this example, the superclass of TandemBike, RoadBike and MountainBike. Every class in Java programming language consists of one superclass which holds potential of unlimited subclasses: