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

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

PDF
java inheritance that is used in oop cls
hassanshahzad1502
 
PPTX
Inheritance in Java - An Introduction & types
VijethaChandran
 
PPTX
Inheritance,single,multiple.access rulepptx
ArunPatrick2
 
PPTX
Java presention Inheritance present By Showrov Ahamed
Md Showrov Ahmed
 
PPTX
Inheritance-in-Java.pptxxxxxxxxxxxxxxxxx
sancharipanda4
 
PPTX
Inheritance in OOPs with java
AAKANKSHA JAIN
 
PPTX
SAD04 - Inheritance
Michael Heron
 
DOCX
159747608 a-training-report-on
homeworkping7
 
PPTX
Multiple inheritance in java3 (1).pptx
RkGupta83
 
PPTX
Inheritance in Java beginner to advance with examples.pptx
naeemcse
 
PPT
Inheritance and its necessity in java.ppt
ssuserf170c4
 
PDF
How to Implement Hierarchical Inheritance in Java: A Step-by-Step Guide
pallavichauhan2525
 
PPTX
INHERTANCE , NARROW AND WIDENING
ManpreetSingh1387
 
PDF
4th_class.pdf
RumiHossain5
 
PPTX
Inheritance in java
Tech_MX
 
PPT
Java_notes.ppt
tuyambazejeanclaude
 
PPTX
Lecture 12
talha ijaz
 
PPTX
ITTutor Advanced Java (1).pptx
kristinatemen
 
PPT
Unit 3 Java
arnold 7490
 
DOCX
Java Interview Questions For Freshers
zynofustechnology
 
java inheritance that is used in oop cls
hassanshahzad1502
 
Inheritance in Java - An Introduction & types
VijethaChandran
 
Inheritance,single,multiple.access rulepptx
ArunPatrick2
 
Java presention Inheritance present By Showrov Ahamed
Md Showrov Ahmed
 
Inheritance-in-Java.pptxxxxxxxxxxxxxxxxx
sancharipanda4
 
Inheritance in OOPs with java
AAKANKSHA JAIN
 
SAD04 - Inheritance
Michael Heron
 
159747608 a-training-report-on
homeworkping7
 
Multiple inheritance in java3 (1).pptx
RkGupta83
 
Inheritance in Java beginner to advance with examples.pptx
naeemcse
 
Inheritance and its necessity in java.ppt
ssuserf170c4
 
How to Implement Hierarchical Inheritance in Java: A Step-by-Step Guide
pallavichauhan2525
 
INHERTANCE , NARROW AND WIDENING
ManpreetSingh1387
 
4th_class.pdf
RumiHossain5
 
Inheritance in java
Tech_MX
 
Java_notes.ppt
tuyambazejeanclaude
 
Lecture 12
talha ijaz
 
ITTutor Advanced Java (1).pptx
kristinatemen
 
Unit 3 Java
arnold 7490
 
Java Interview Questions For Freshers
zynofustechnology
 

More from kritikumar16 (10)

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

Recently uploaded (20)

PPTX
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
PPTX
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PPTX
TRANSLATIONAL AND ROTATIONAL MOTION.pptx
KIPAIZAGABAWA1
 
PPTX
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PPTX
DIGITAL CITIZENSHIP TOPIC TLE 8 MATATAG CURRICULUM
ROBERTAUGUSTINEFRANC
 
PPTX
Difference between write and update in odoo 18
Celine George
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PDF
Council of Chalcedon Re-Examined
Smiling Lungs
 
PDF
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
PDF
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PDF
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
PPTX
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PDF
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
TRANSLATIONAL AND ROTATIONAL MOTION.pptx
KIPAIZAGABAWA1
 
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
DIGITAL CITIZENSHIP TOPIC TLE 8 MATATAG CURRICULUM
ROBERTAUGUSTINEFRANC
 
Difference between write and update in odoo 18
Celine George
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
Council of Chalcedon Re-Examined
Smiling Lungs
 
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
Ad

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/