SlideShare a Scribd company logo
INHERITANCE IN JAVA
What is Inheritance
Inheritance is a
process by which
one class
acquires the
properties (fields
and methods) of
another class
Inheritance
 Top class in know as a parent or base
class or super class
 Class inheriting features is known as
child class, sub class
 Inheritance is “IS A” relationship
between base and child class.
Syntax of Inheritance
class ChildClass
extends BaseClass{
}
class Studnet extends Person{
}
class Professor extends Person{
}
Types of Inheritance
 Single level Inheritance
 Multi-level Inheritance
 Hierarchical Inheritance
 Hybrid Inheritance
Single level Inheritance
 Only one class inherits the properties of
base class
Single level Inheritance
Example
 class A {
 int a = 7;
 }
 class B extends A {
 int b = 10;
 }
 public class TestIn1 {
 public static void main(String[] s) {
 B obj = new B();
 System.out.println("values are a="
+ obj.a + " b=" + obj.b);
 }
 }
Multi level Inheritance
 One class inherits the properties of another
class.
 One more class inherits the properties of
inherited class
Multi level Inheritance
Example
 class A {
 int a = 7;
 }
 class B extends A {
 int b = 10;
 }
 class C extends B {
 int c = 12;
 }
 public class TestIn2 {
 public static void main(String[] s) {
 C obj = new C();
 System.out.println("values are a=" + obj.a + "
b=" + obj.b + " c=" + obj.c);
 }
 }
Hierarchical Inheritance
 More then one class inherits the property
on base class.
Hierarchical Inheritance
Example
 class A {
 int a = 7;
 }
 class B extends A {
 int b = 10;
 }
 class C extends A {
 int c = 12;
 }
 public class TestIn3 {
 public static void main(String[] s) {
 B objB = new B();
 System.out.println("values are a=" + objB.a + " b=" + objB.b);
 C objC = new C();
 System.out.println("values are a=" + objC.a + " c=" + objC.c);
 }
 }
Hybrid Inheritance
 Combination of above of inheritance
types
Hybrid Inheritance Example
 class A {
 int a = 7;
 void display() {
 System.out.println("values are a=" + a);
 }
 }
 class B extends A {
 int b = 10;
 }
 class C extends A {
 int c = 12;
 }
 class D extends B {
 int d = 15;
 }
 public class TestIn4 {
 public static void main(String[] s) {
 D objD = new D();
 System.out.println("values are a=" + objD.a + " b=" + objD.b + " d=" + objD.d);
 objD.display();
 C objC = new C();
 System.out.println("values are a=" + objC.a + " c=" + objC.c);
 }
 }
References
 https://docs.oracle.com/javase/tutorial/ja
va/IandI/subclasses.html
 https://www.ebhor.com/java-inheritance/
Thank you

More Related Content

What's hot

Java Serialization
Java SerializationJava Serialization
Java Serialization
imypraz
 
Java Presentation
Java PresentationJava Presentation
Java Presentation
pm2214
 
Method Overloading In Java
Method Overloading In JavaMethod Overloading In Java
Method Overloading In Java
CharthaGaglani
 
Inheritance in OOPS
Inheritance in OOPSInheritance in OOPS
Inheritance in OOPS
Ronak Chhajed
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
kamal kotecha
 
Inner classes in java
Inner classes in javaInner classes in java
Inner classes in java
PhD Research Scholar
 
Introduction to method overloading & method overriding in java hdm
Introduction to method overloading & method overriding  in java  hdmIntroduction to method overloading & method overriding  in java  hdm
Introduction to method overloading & method overriding in java hdm
Harshal Misalkar
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Tushar B Kute
 
Inheritance
InheritanceInheritance
Inheritance
Sapna Sharma
 
Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVA
Abhilash Nair
 
Inheritance
InheritanceInheritance
Java Streams
Java StreamsJava Streams
Java Streams
M Vishnuvardhan Reddy
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
Michelle Anne Meralpis
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
Hitesh Kumar
 
Introduction to class in java
Introduction to class in javaIntroduction to class in java
Introduction to class in java
kamal kotecha
 
Java Networking
Java NetworkingJava Networking
Java Networking
Sunil OS
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
Madishetty Prathibha
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
arvind pandey
 
Important features of java
Important features of javaImportant features of java
Important features of java
AL- AMIN
 
Type casting in java
Type casting in javaType casting in java
Type casting in java
Farooq Baloch
 

What's hot (20)

Java Serialization
Java SerializationJava Serialization
Java Serialization
 
Java Presentation
Java PresentationJava Presentation
Java Presentation
 
Method Overloading In Java
Method Overloading In JavaMethod Overloading In Java
Method Overloading In Java
 
Inheritance in OOPS
Inheritance in OOPSInheritance in OOPS
Inheritance in OOPS
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 
Inner classes in java
Inner classes in javaInner classes in java
Inner classes in java
 
Introduction to method overloading & method overriding in java hdm
Introduction to method overloading & method overriding  in java  hdmIntroduction to method overloading & method overriding  in java  hdm
Introduction to method overloading & method overriding in java hdm
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
 
Inheritance
InheritanceInheritance
Inheritance
 
Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVA
 
Inheritance
InheritanceInheritance
Inheritance
 
Java Streams
Java StreamsJava Streams
Java Streams
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
Introduction to class in java
Introduction to class in javaIntroduction to class in java
Introduction to class in java
 
Java Networking
Java NetworkingJava Networking
Java Networking
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
 
Important features of java
Important features of javaImportant features of java
Important features of java
 
Type casting in java
Type casting in javaType casting in java
Type casting in java
 

Similar to Inheritance In Java

Learn Java Part 11
Learn Java Part 11Learn Java Part 11
Learn Java Part 11
Gurpreet singh
 
Learn Java Part 11
Learn Java Part 11Learn Java Part 11
Learn Java Part 11
Gurpreet singh
 
Inheritance and Interfaces
Inheritance and InterfacesInheritance and Interfaces
Inheritance and Interfaces
NAGASURESH MANOHARAN
 
Inheritance In Java
Inheritance In JavaInheritance In Java
Inheritance In Java
Darpan Chelani
 
Inheritance
InheritanceInheritance
Inheritance
SangeethaSasi1
 
Java
JavaJava
Lecture 14 (inheritance basics)
Lecture 14 (inheritance basics)Lecture 14 (inheritance basics)
Lecture 14 (inheritance basics)
Abhishek Khune
 
OOPS IN C++
OOPS IN C++OOPS IN C++
OOPS IN C++
Amritsinghmehra
 
Oopc (group 9)
Oopc (group 9)Oopc (group 9)
Oopc (group 9)
Xyber Prince
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
Laxman Puri
 
‫Chapter3 inheritance
‫Chapter3 inheritance‫Chapter3 inheritance
‫Chapter3 inheritance
Mahmoud Alfarra
 
Inheritance
InheritanceInheritance
Inheritance
Jancirani Selvam
 
Inheritance_abstractclass_interface.pdf
Inheritance_abstractclass_interface.pdfInheritance_abstractclass_interface.pdf
Inheritance_abstractclass_interface.pdf
kshitijsaini9
 
c++Inheritance.pdf
c++Inheritance.pdfc++Inheritance.pdf
c++Inheritance.pdf
RanjanaThakuria1
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
Ariful Islam
 
Inheritance in java
Inheritance in java Inheritance in java
Inheritance in java
yash jain
 
Inheritance
InheritanceInheritance
Inheritance
Misbah Aazmi
 
Java inheritance
Java inheritanceJava inheritance
Java inheritance
BHUVIJAYAVELU
 
Inheritance
InheritanceInheritance
Inheritance
prabhat kumar
 
Inheritance and interface
Inheritance and interfaceInheritance and interface
Inheritance and interface
Shubham Sharma
 

Similar to Inheritance In Java (20)

Learn Java Part 11
Learn Java Part 11Learn Java Part 11
Learn Java Part 11
 
Learn Java Part 11
Learn Java Part 11Learn Java Part 11
Learn Java Part 11
 
Inheritance and Interfaces
Inheritance and InterfacesInheritance and Interfaces
Inheritance and Interfaces
 
Inheritance In Java
Inheritance In JavaInheritance In Java
Inheritance In Java
 
Inheritance
InheritanceInheritance
Inheritance
 
Java
JavaJava
Java
 
Lecture 14 (inheritance basics)
Lecture 14 (inheritance basics)Lecture 14 (inheritance basics)
Lecture 14 (inheritance basics)
 
OOPS IN C++
OOPS IN C++OOPS IN C++
OOPS IN C++
 
Oopc (group 9)
Oopc (group 9)Oopc (group 9)
Oopc (group 9)
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
 
‫Chapter3 inheritance
‫Chapter3 inheritance‫Chapter3 inheritance
‫Chapter3 inheritance
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance_abstractclass_interface.pdf
Inheritance_abstractclass_interface.pdfInheritance_abstractclass_interface.pdf
Inheritance_abstractclass_interface.pdf
 
c++Inheritance.pdf
c++Inheritance.pdfc++Inheritance.pdf
c++Inheritance.pdf
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Inheritance in java
Inheritance in java Inheritance in java
Inheritance in java
 
Inheritance
InheritanceInheritance
Inheritance
 
Java inheritance
Java inheritanceJava inheritance
Java inheritance
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance and interface
Inheritance and interfaceInheritance and interface
Inheritance and interface
 

Recently uploaded

Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
danielkiash986
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
iammrhaywood
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
HajraNaeem15
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
haiqairshad
 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
zuzanka
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
siemaillard
 
Stack Memory Organization of 8086 Microprocessor
Stack Memory Organization of 8086 MicroprocessorStack Memory Organization of 8086 Microprocessor
Stack Memory Organization of 8086 Microprocessor
JomonJoseph58
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Denish Jangid
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
MysoreMuleSoftMeetup
 
Nutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour TrainingNutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour Training
melliereed
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
giancarloi8888
 
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
National Information Standards Organization (NISO)
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
nitinpv4ai
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
zuzanka
 

Recently uploaded (20)

Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
 
Stack Memory Organization of 8086 Microprocessor
Stack Memory Organization of 8086 MicroprocessorStack Memory Organization of 8086 Microprocessor
Stack Memory Organization of 8086 Microprocessor
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
 
Nutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour TrainingNutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour Training
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
 
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
 

Inheritance In Java

  • 2. What is Inheritance Inheritance is a process by which one class acquires the properties (fields and methods) of another class
  • 3. Inheritance  Top class in know as a parent or base class or super class  Class inheriting features is known as child class, sub class  Inheritance is “IS A” relationship between base and child class.
  • 4. Syntax of Inheritance class ChildClass extends BaseClass{ } class Studnet extends Person{ } class Professor extends Person{ }
  • 5. Types of Inheritance  Single level Inheritance  Multi-level Inheritance  Hierarchical Inheritance  Hybrid Inheritance
  • 6. Single level Inheritance  Only one class inherits the properties of base class
  • 7. Single level Inheritance Example  class A {  int a = 7;  }  class B extends A {  int b = 10;  }  public class TestIn1 {  public static void main(String[] s) {  B obj = new B();  System.out.println("values are a=" + obj.a + " b=" + obj.b);  }  }
  • 8. Multi level Inheritance  One class inherits the properties of another class.  One more class inherits the properties of inherited class
  • 9. Multi level Inheritance Example  class A {  int a = 7;  }  class B extends A {  int b = 10;  }  class C extends B {  int c = 12;  }  public class TestIn2 {  public static void main(String[] s) {  C obj = new C();  System.out.println("values are a=" + obj.a + " b=" + obj.b + " c=" + obj.c);  }  }
  • 10. Hierarchical Inheritance  More then one class inherits the property on base class.
  • 11. Hierarchical Inheritance Example  class A {  int a = 7;  }  class B extends A {  int b = 10;  }  class C extends A {  int c = 12;  }  public class TestIn3 {  public static void main(String[] s) {  B objB = new B();  System.out.println("values are a=" + objB.a + " b=" + objB.b);  C objC = new C();  System.out.println("values are a=" + objC.a + " c=" + objC.c);  }  }
  • 12. Hybrid Inheritance  Combination of above of inheritance types
  • 13. Hybrid Inheritance Example  class A {  int a = 7;  void display() {  System.out.println("values are a=" + a);  }  }  class B extends A {  int b = 10;  }  class C extends A {  int c = 12;  }  class D extends B {  int d = 15;  }  public class TestIn4 {  public static void main(String[] s) {  D objD = new D();  System.out.println("values are a=" + objD.a + " b=" + objD.b + " d=" + objD.d);  objD.display();  C objC = new C();  System.out.println("values are a=" + objC.a + " c=" + objC.c);  }  }