Types of Inheritance in Java

JAVA

  1. Single or simple inheritance -> Single or simple inheritance is those type of inheritance in which a single super class is used to create single subclass. Inheritance visibility of component can not be change in java graphically we can represent single/simple inheritance as.
  2. JAVA

  3. Multilevel inheritance -> Multilevel inheritance is those type of inheritance in which a sub class is used as a super class to create another sub class .alternately we can say that multilevel inheritance is the representation of single inheritance. Graphically we can represent multilevel inheritance as.
  4. JAVA

  5. Hierarchical/Tree structure inheritance ->Hierarchical or tree structure inheritance is those type of inheritance in which every subclass has only one super class. But every super class can be more than one sub class. graphically we can represent heretical/ tree structure inheritance as-
  6. JAVA

In inheritance the concept of overwriting and overriding is arise if an instance variable is inherit from super class to subclass than in subclass new value can be supplied to the variable . the new overwrites the executing value of the variable .in the variable the concept of overwriting is implemented . If user wants to restrict the overwriting than the final keyword is used before the general declaration of the variable. The final variable can not can not be overwrite in the subclass . That means final keyword create constant that values can not be changed in subclass. Function present in subclass can be inherited into subclass and new definition of the function can be created by the user in sub classes. the new definition of the function of subclass overwrite the executing definition of function in super class in subclass new definition is active and in super class the old definition is user want to protect function overwriting than the final keyword is used before the general definition of the function . The final keyword can not restrict the inheritance of the method and instance variable it only restrict only overwriting and overriding. If class is final than class can not be inherit into subclass the final keyword protect the extension of class in java subclass is the extension of the super class and so final keyword restrict the extension. Abstract class:- Abstract class is that type of the class which has no capacity to create object. Abstract class must be inherit into subclass to create existence of the abstract class. Abstract class is used as a super class in inheritance. Abstract Function:- Abstract function is that type of function which has no definition or body, if a class contains an abstract function than the class must be also an abstract.

This blog written by Jitendra Kumar (Java Trainer at Vtech Academy of Computers)- Java Training Institute in Delhi

0 Responses

  1. December 20, 2016 / 10:05 am

    Your comment is awaiting moderation.

Leave a Reply

Your email address will not be published. Required fields are marked *