Inheritance in Java
Skip to main content

Inheritance in Java

  

inheritance in java definition, inheritance in java example, inheritance in java example programs, inheritance in java in hindi, inheritance in java interview questions, inheritance in java types, inheritance in javascript, inheritance in java code, types of inheritance, types of inheritance in java, types of inheritance in python, types of inheritance in oops, types of inheritance genetics, types of inheritance java






 Inheritance in Java :-

         This tutorial is explain about What is a Inheritance in Java and also explain about types of inheritance and explanation and given example of Java Programming. 

Inheritance:- when create a child class that extended by the super class and the child class access all the features and properties of the super class is called a Inheritance. In Inheritance, we cannot access private members of super class.

Syntax :-  There is defind class A that is super class and its statment inside this class body. There is anothere class declare class B its called a child class and Its statement inside this class. Accessing of super class A  functions, variables and statments by the class B using extends keyword.

class A{

      Statments;

}

class B extends class A{

   Statements;

}


Type of Inheritance:-

1. Single level Inheritance

2.  Multi level Inheritance

3. Multiple level Inheritance

4. Hierarchical Inheritance


 1. Single level Inheritance:- In a single level Inheritance you define a super class  A  and child class B  access all the properties and features of super class A. There is only one super class and a single child class use so this is called single level Inheritance.

class A{

      Statements;

}

class B extends class A{

   Statements;

}

2. Multi Level Inheritance:- In this inheritance you use  super class A and this super class extends by child class B and access properties and features. After that child class C is extends by the super class B so class B is super class of class C and child class C access features and properties of class B. So this type of Inheritance is called multi Level Inheritance.

class A{

      Statments;

}

class B extends class A{

   Statements;

}

class C extends class B{

   Statements;

}


3. Hierarchical Inheritance:- There is you define a super class and its features and properties use by more then one child class is called Hierarchical Inheritance.

Example:-

class A{

      Statments;

}

class B extends class A{

   Statements;

}

class C extends class A{

   Statements;

}

4. Multiple Inheritance:-  there is you define two super class and extends by single child class is called multiple Inheritance. For Example:- 

class A{

   Statements;

}

class B {

   Statements;

}

class C extends class A, class B{

   Statements;

}

Note:- Java is not supported the multiple Inheritance because of  there is not clear so first remove ambiguity and  provide a clear design its require a more maintaince.


Post a Comment

0 Comments