It is a concept in java which provide the re usability of the members of one class/object to another class/object. Inheritance term itself defines the property inheriting. In java we are working with class so here we are going to inherit the property of one class into another i.e we are reusing the unresticted members of one class into other class who is inheriting that class. Now before going into depth you need to understand two term
1> Super class / parent class / inherited class.
2> Sub class / child class / inheriting class.

Super class

In java super class is the parents class of all the class who is inheriting that class. By default Object class of lang package is the super class of all class. By inheriting the super class we are free to use all the unrestricted member into subclass for our own custom implementation. Like by extending predefined classes we are using predefined methods .

Sub class

Subclass is the child class and is inheriting the members of its super class. For inheriting any class we need to use the extends keyword so that JVM will understand that a class is being inherited by another class.
The class which is going to use extend keyword is known as sub-class. For ex-

class A { }                                             
public class B extends A { } 

Here in the above program class B is extending class A that means
B --> Subclass
A --> super class 
and by default A is extending Object class that means A is subclass for Object class. So here is the Hierarchy for the above program how it is inheriting each other.



So now according to inheriting classes we can categorize inheritance into six category

1.  Simple Inheritance
2.  Multiple Inheritance  ( Not supported In java )
3.  Multi-level Inheritance
4.  Hierarchical Inheritance
5.  Hybrid Inheritance
6.  Cyclic Inheritance

For details on the above types of inheritance follow click here !


Related Posts:

  • Increments (++) and Decrements (--) Operators in Java This is most useful and confusing operator in java or any programming language. It is used to increase and decrease the value of a variable by 1. It is a Unary operator but the operand must be a variable containing num… Read More
  • Relational Operator in Java Relational Operator in Java is used where we use any comparison between two value or two variable or a value and a variable, but while comparing variables , it must some numeral value and hence all the operators used for … Read More
  • Assignment Operator ( = ) in Java It is a kind of operator which has a wide use in any programming language and as it name suggest it is used to assign value to a variable and that value may be a direct value or a variable or we can say that it is used to a… Read More
  • Logical and bit-wise operators in java In java both logical and bitwise operators are used. Logical operator returns the true / false value depends on the condition check and bitwise return the same true / false depends on the condition check but the difference … Read More
  • " new " and " instanceof " Operator in Java new operator refers to the object creation where as instanceof used with the reference variable. Details of which we are going to discuss late in this topic.  What is " new " Operator and its uses in Java ? … Read More

1 comment:

Blog Archive

Ads 468x60px

.

Ads

.

Featured Posts

Popular Posts

Like Us On FaceBook

Total Pageviews

201976

Online Members

Live Traffic