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:

  • java.lang.CharSequence It is the only abstract interface in the java.lang package. It is the basic interface containing non-implemented methods all regarding and involving characters only like length() , charAt() etc and a special method i.e to… Read More
  • How to convert primitive to string in Java Basically there are three way to convert an primitive value to string so that if we have requirement to use that primitive as a string then we can you this concept and way of conversion but now the point is out of these thre… Read More
  • Java.lang package Java is using java.lang as the default package.All the basic functionality for writing a simple java program are there written in the form of classes and interfaces and also designed some of the possible and probable excep… Read More
  • java.lang.AbstractStringBuilder It is a private class or more specifically we can say its a ' private - package ' class i.e it is declared as not public and as abstract. As it was not there before the release of JDK 1.5 and was first introduced in java … Read More
  • String in Java String is a reference data type and hence string literals are treated as object and get stored in the string constant pool. We must have to define any string within double-quote otherwise it will give compilation error. Str… Read More

1 comment:

Blog Archive

Ads 468x60px

.

Ads

.

Featured Posts

Popular Posts

Like Us On FaceBook

Total Pageviews

201978

Online Members

Live Traffic