Inheritance in java - PowerPoint PPT Presentation

About This Presentation
Title:

Inheritance in java

Description:

The Java certification can be categorized into five levels based on the skills – associate, professional, expert, and master. Here is a list of the certifications levels structured under the Oracle’s Java certification path. – PowerPoint PPT presentation

Number of Views:4546
Slides: 8
Provided by: priya99
Category: Other
Tags: java

less

Transcript and Presenter's Notes

Title: Inheritance in java


1
Inheritance in Java
  • For more details visit this link
  • https//www.besanttechnologies.com/training-course
    s/java-training-in-bangalore

2
inheritance in java
  • What is Inheritance?
  •  
  • Inheritance is a mechanism in which one class
    acquires the property of another class. For
    example, a child inherits the traits of his/her
    parents. With inheritance, we can reuse the
    fields and methods of the existing class. Hence,
    inheritance facilitates Reusability and is an
    important concept of OOPs.
  • Get 100 Practical Java training
  •  

3
Important terminology
  •  Super Class The class whose features are
    inherited is known as super class(or a base class
    or a parent class).
  • Sub Class The class that inherits the other
    class is known as sub class(or a derived class,
    extended class, or child class). The subclass can
    add its own fields and methods in addition to the
    superclass fields and methods.
  • Reusability Inheritance supports the concept of
    reusability, i.e. when we want to create a new
    class and there is already a class that includes
    some of the code that we want, we can derive our
    new class from the existing class. By doing this,
    we are reusing the fields and methods of the
    existing class.

4
Types of Inheritance in Java
  • There are Two Types of Inheritance
  • Single Inheritance
  • Mulilevel Inheritance
  • Multiple Inheritance
  • Hierarchical Inheritance
  • Hybrid Inheritance

5
Types of Inheritance in Java
  • Single Inheritance
  • In the concept of single inheritance, one class
    provides an extension to another class (only one
    class). It simply means that class A extends to
    class B. In such a way, Class B extends only
    class A. This way class A is known as a
    superclass and class B is known as the subclass.
  • Multilevel Inheritance
  • In this, one class can access and inherit
    properties from the derived class. Thus, the
    derived class becomes the base class for the new
    class. For instance, class C is considered as the
    subclass of B and B is the subclass of class A.

6
Types of Inheritance in Java
  • Hierarchical Inheritance
  • In this concept of hierarchical inheritance, one
    class is inherited by many subclasses. For
    instance, class A, B, and C inherit the same
    class D.
  • Multiple Inheritance
  • In the concept of multiple inheritances, one
    class extends more than one class. Hence, Java is
    not able to support multiple inheritances. For
    instance, class C extends both class A and class
    B respectively.
  • Hybrid Inheritance
  • It is just a combination of single and multiple
    inheritances. For instance, all the protected and
    public members of class A are inherited into the
    class D, first through class B and another
    through class C.

7
Thank you
Write a Comment
User Comments (0)
About PowerShow.com