SlideShare a Scribd company logo
How do I use inheritance in Java?
Index
What is Java inheritance
Example of Java inheritance
Keywords Extends
Prepared By
Preeti
Java class supports reuse through inheritance and composition. This
two-part tutorial shows you how to use inheritance in your Java
programs. In Part 1, Learn how to use the extends keyword to derive a
child from a parent class. In part 2 you will visit java.long.Object, this is
the superclass of Java, from which any other class inherits.
All freshers who willing to make career in java ,Java certification
course is a essential to all freshers.
To complete your knowledge about inheritance, check my Java tip, if
you want to use composition vs inheritance.
Learn why composition is an important addition to inheritance and how
to use it to avoid encapsulation problems in your Java programs.
To complete your knowledge about inheritance, check my Java tip, if
you want to use composition vs inheritance.
Learn why composition is an important addition to inheritance and how
to use it to avoid encapsulation problems in your Java programs.
Java Inheritance: Two Examples
Inheritance is a programming construct that software developers use to
create is-a relationships between categories.
By inheritance, we can derive more specific categories from more
generic ones. The more specific category is a type of generic category.
For example, a current account is a type of account where you can
deposit and withdraw funds.
Similarly, a truck is a kind of vehicle for towing large objects.
Inheritance can descend through multiple levels, leading to more and
more specific categories.
As an example, figure shows the number 1 car and truck inherit from
vehicle; Combi inherit from car, and garbage truck inherit from truck.
Arrows show from more specific "child" categories (below) to less
specific "parents"categories (above).
Figure 1. A few inheritance hierarchies are rooted in the common
vehicle category
This example demonstrates single inheritance in which a child category
inherits state and behavior from an immediate parent category.
In contrast, multiple inheritance a child category to inherit state and
behavior from two or more parent categories.
The hierarchy in Figure 2 illustrates the Multiple Inheritance.
https://www.exltech.in/java-training.html
Figure 2.
Hovercraft multiply inherits from land vehicle and watercraft categories
Categories are described by classes.
Java supports single inheritance through class extension, in which a
class inherits directly accessible fields and methods from another class
by extending this class. However,
Java does
When you view an inheritance hierarchy, you can easily detect multiple
inherits by the presence of a diamond pattern.
Figure 2 shows this pattern in the context of vehicle, land vehicle,
watercraft and hovercraft.
The keyword extends
Java supports the class extension using the extends keyword. If present,
extends specifies a parent-child relationship between two classes.
Below I use extended to a relationship between the classes vehicle and
car, and then between Account and SavingsAccount:
Exltech is offering Practical Java course training in Pune with hands on
experienced in coding.
Vist us to know more details about Java course
https://www.exltech.in/

More Related Content

PDF
What are Generics in Java | Java Generics Tutorial | Edureka
PPTX
Java syntax-and-grammars-oct8
PPTX
Inheritance
PDF
IRJET- Inheritance in Java
PPTX
Inheritance in java.pptx_20241025_101324_0000.pptx.pptx
PPTX
inheritance.pptxfdfgfgfgfgdfgfgdfgdfgerre
PPTX
Inheritance in Java is a mechanism in which one object acquires all the prope...
PDF
Inheritance in Java.pdf
What are Generics in Java | Java Generics Tutorial | Edureka
Java syntax-and-grammars-oct8
Inheritance
IRJET- Inheritance in Java
Inheritance in java.pptx_20241025_101324_0000.pptx.pptx
inheritance.pptxfdfgfgfgfgdfgfgdfgdfgerre
Inheritance in Java is a mechanism in which one object acquires all the prope...
Inheritance in Java.pdf

Similar to How do i use inheritance in java? (20)

PPTX
Inheritance in OOPs with java
PPTX
Inheritance-in-Java.pptxxxxxxxxxxxxxxxxx
PPTX
Java Inheritance
PPTX
Basics to java programming and concepts of java
PPTX
Java - Inheritance_multiple_inheritance.pptx
PPTX
Inheritance in oop
PPTX
java_inheritance_oop_20250730110153.pptx
PDF
Introduction to Inheritance in Java for presentation
PPTX
Inheritance & interface ppt Inheritance
PPTX
Inheritance in Java
PDF
java_vyshali.pdf
PDF
Inheritance_abstractclass_interface.pdf
PDF
Inheritance used in java
PPTX
Ayan Das_25300121057.pptx
PDF
Object Oriented Programming - 7.1. Inheritance
PPTX
Inheritance in java
PPTX
Inheritance
PPTX
Inheritance in Java,Type of Inheritance,Method overriding
PPTX
Inheritance in Java
PPTX
Inheritance in java
Inheritance in OOPs with java
Inheritance-in-Java.pptxxxxxxxxxxxxxxxxx
Java Inheritance
Basics to java programming and concepts of java
Java - Inheritance_multiple_inheritance.pptx
Inheritance in oop
java_inheritance_oop_20250730110153.pptx
Introduction to Inheritance in Java for presentation
Inheritance & interface ppt Inheritance
Inheritance in Java
java_vyshali.pdf
Inheritance_abstractclass_interface.pdf
Inheritance used in java
Ayan Das_25300121057.pptx
Object Oriented Programming - 7.1. Inheritance
Inheritance in java
Inheritance
Inheritance in Java,Type of Inheritance,Method overriding
Inheritance in Java
Inheritance in java
Ad

More from kritikumar16 (10)

PPTX
How do i implement command design pattern in the java programming course with...
PPTX
When to use abstract class and methods in java
PPTX
How do i use inheritance in java?
PPTX
5 things about introduction to advanced java you have to experience it yourself.
PPTX
How do i use inheritance in java?
PPTX
List of 7 popular java frameworks for 2019
PPTX
What is java polymorphism and its types in java training?
PPTX
How do i implement command design pattern in the java programming course with...
PPTX
List of 7 popular java frameworks for 2019
PPTX
Introduction to advanced java
How do i implement command design pattern in the java programming course with...
When to use abstract class and methods in java
How do i use inheritance in java?
5 things about introduction to advanced java you have to experience it yourself.
How do i use inheritance in java?
List of 7 popular java frameworks for 2019
What is java polymorphism and its types in java training?
How do i implement command design pattern in the java programming course with...
List of 7 popular java frameworks for 2019
Introduction to advanced java
Ad

Recently uploaded (20)

PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Institutional Correction lecture only . . .
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Classroom Observation Tools for Teachers
PPTX
Cell Structure & Organelles in detailed.
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Pharma ospi slides which help in ospi learning
PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
VCE English Exam - Section C Student Revision Booklet
Institutional Correction lecture only . . .
O7-L3 Supply Chain Operations - ICLT Program
Final Presentation General Medicine 03-08-2024.pptx
O5-L3 Freight Transport Ops (International) V1.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Microbial diseases, their pathogenesis and prophylaxis
Classroom Observation Tools for Teachers
Cell Structure & Organelles in detailed.
102 student loan defaulters named and shamed – Is someone you know on the list?
Pharma ospi slides which help in ospi learning
A systematic review of self-coping strategies used by university students to ...
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
2.FourierTransform-ShortQuestionswithAnswers.pdf
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
FourierSeries-QuestionsWithAnswers(Part-A).pdf
human mycosis Human fungal infections are called human mycosis..pptx
Chinmaya Tiranga quiz Grand Finale.pdf
Microbial disease of the cardiovascular and lymphatic systems

How do i use inheritance in java?

  • 1. How do I use inheritance in Java?
  • 2. Index What is Java inheritance Example of Java inheritance Keywords Extends
  • 4. Java class supports reuse through inheritance and composition. This two-part tutorial shows you how to use inheritance in your Java programs. In Part 1, Learn how to use the extends keyword to derive a child from a parent class. In part 2 you will visit java.long.Object, this is the superclass of Java, from which any other class inherits. All freshers who willing to make career in java ,Java certification course is a essential to all freshers. To complete your knowledge about inheritance, check my Java tip, if you want to use composition vs inheritance. Learn why composition is an important addition to inheritance and how to use it to avoid encapsulation problems in your Java programs.
  • 5. To complete your knowledge about inheritance, check my Java tip, if you want to use composition vs inheritance. Learn why composition is an important addition to inheritance and how to use it to avoid encapsulation problems in your Java programs. Java Inheritance: Two Examples Inheritance is a programming construct that software developers use to create is-a relationships between categories. By inheritance, we can derive more specific categories from more generic ones. The more specific category is a type of generic category. For example, a current account is a type of account where you can deposit and withdraw funds. Similarly, a truck is a kind of vehicle for towing large objects.
  • 6. Inheritance can descend through multiple levels, leading to more and more specific categories. As an example, figure shows the number 1 car and truck inherit from vehicle; Combi inherit from car, and garbage truck inherit from truck. Arrows show from more specific "child" categories (below) to less specific "parents"categories (above). Figure 1. A few inheritance hierarchies are rooted in the common vehicle category This example demonstrates single inheritance in which a child category inherits state and behavior from an immediate parent category.
  • 7. In contrast, multiple inheritance a child category to inherit state and behavior from two or more parent categories. The hierarchy in Figure 2 illustrates the Multiple Inheritance.
  • 8. https://www.exltech.in/java-training.html Figure 2. Hovercraft multiply inherits from land vehicle and watercraft categories Categories are described by classes. Java supports single inheritance through class extension, in which a class inherits directly accessible fields and methods from another class by extending this class. However, Java does
  • 9. When you view an inheritance hierarchy, you can easily detect multiple inherits by the presence of a diamond pattern. Figure 2 shows this pattern in the context of vehicle, land vehicle, watercraft and hovercraft.
  • 10. The keyword extends Java supports the class extension using the extends keyword. If present, extends specifies a parent-child relationship between two classes. Below I use extended to a relationship between the classes vehicle and car, and then between Account and SavingsAccount:
  • 11. Exltech is offering Practical Java course training in Pune with hands on experienced in coding. Vist us to know more details about Java course https://www.exltech.in/