Implementation of Inheritance includes 2 type... They are, 1.Inheriting Class ([access_specifier] class Sub extends Super) 2.Inheriting Interface ([access_specifier] class Sub implements Super1,Super2)
In Java programming, inheritance provides user to create a class that uses the properties or qualities of previous defined class, but defined class still uses its own properties. In example of inheritance in Java, I give you the example of a flower program. Suppose that you have a flower class in which you create the qualities of a flower like color, smell, type etc .Now you want to create a class that describes the types of flowers and this class uses the types as rose, sunflower, Lilly etc.
In a normal or simple program, you might have to modify the existing code vastly. But now you want to avoid the difficulty of extended old class, you use the object-oriented approach and create a new class. The new class created by inheritance; this new class (type) inherits all the data and methods from the tested old class (flower).
In inheritance you can use public, private, and protected keywords for control the level of inheritance. You create a new class which is known as child or derived class from a parent or superclass by using extends keyword; with the name of a keyword extends use in child class because you usually extend the abilities of the parent class. For example you have already created Flower class and now you are creating a subclass FlowerTypes.
Import Flower; Class FlowerTypes extends Flower Private Int myType; Public FlowerTypes (int value) Super (value); myType = value; Public void SetType (int value) myType = value; Public int GetType () return myType;