Object Oriented Programming in JAVA – Inheritance | Angular | ASP.NET Tutorials

For Consultation : +91 9887575540

Stay Connected :

Object Oriented Programming in JAVA – Inheritance 

What is Inheritance?

  • The main purpose of the inheritance is code extensibility whenever we are extending automatically the code is reused.
  • In inheritance one class giving the properties and behavior and another class is taking the properties and behavior.
  • Inheritance is also known as is-a relationship means two classes are belongs to the same hierarchy.
  • By using extends keyword we are achieving inheritance concept.
  • In the inheritance the person who is giving the properties is called parent the person who is taking the properties is called child.
  • To reduce length of the code and redundancy of the code sun peoples introducing inheritance concept.

Types of Inheritance


Another Inheritance


class ParentClass {
      public void P1()
	System.out.println("Parent Class Method is called");
 class childclass extends ParentClass{
	 public void C1()
	 	System.out.println("Child Class Method is called");
	 public void C2()
	 	System.out.println("Child Class Another Method is called");
//For Multilevel Inheritance
class superchildclass extends childclass
	 public void SC1()
	 	System.out.println("Super Child Class Method is called");

public class InheritanceEx {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		childclass cobj=new childclass();
		ParentClass pobj=new ParentClass();
                 //For Multilevel Inheritance
                superchildclass scobj=new superchildclass();


 Download Source Code