SlideShare a Scribd company logo
INHERITANCE
IN JAVA
Content
•What is Inheritance?
•Basic Example of Inheritance in Java
•Types Of Inheritance
•Inheritance By Animal
What Is Inheritance?
Inheritance in java is a
mechanism in which one
object acquires all the
properties and behaviors
of parent object.
Inheritance in Java can be best
understood in terms of Parent
and Child relationship, also
known as Super class(Parent)
and Sub class(child) in Java
language. Inheritance defines a
relationship between a Super
class and its Sub class. extends
and implements keywords are
used to describe inheritance in
Java
BASIC EXAMPLE OF
INHERITANCE IN JAVA
//Creating a SubClass
class A{
int a=10, b=20;
void showab(){
System.out.println(“a: “+a+ “b: ”+b);
}
}
//Creating a SubClass by extanding A class
class B extends A{
void sum(){
System.out.println(“Sum of a and b is: ”+(a+b));
}
}
//Creating Main Class
class Main{
public static void main(String args[]){
A obj1= new A();
obj1.showab();
B obj2= new B();
obj2.sum();
}
}
Output
Inheritance
• As you can see, the subclass B
include all the members of its
super class, A.
• This is why class B can access
“a” and “b” and call showab().
• Also, include sum(), “a” and
“b” can be referred directly, as
if they were part of B class.
• Even though A is super class
for B, it is also a completely
independent, stand alone
class.
TYPES OF
INHERITANCE
TYPES OF INHERITANCE
Based on number of ways inheriting the feature of
base class into derived class we have some types of
inheritance; they are:
• Single inheritance
• Multilevel inheritance
• Hierarchical inheritance
SINGLE INHERITANCE
When a class extends
another one class only then
we call it a single
inheritance.The below flow
diagram shows that class B
extends only one class
which is A. Here A is a
parent class of B and B
would be a child class of A
MULTIPLE INHERITANCE
Here class C inherits class B
and class B inherits class A
which means B is a parent
class of C andA is a parent
class of B. So in this case class
C is implicitly inheriting the
properties and method of class
A along with B that’s what is
called multilevel inheritance.
Hierarchical Inheritance
In this inheritance multiple classes inherits from a single class i.e
there is one super class and multiple sub classes. As we can see
from the below diagram when a same class is having more than
one sub class (or) more than one sub class has the same parent is
called as Hierarchical Inheritance.
TYPES OF INHERITANCE
INHERITANCE BY
ANIMAL
SAMPLE PROGRAM
public class Animal{
}
public class Amphibians extends Animal{
}
public class Reptiles extends Animal{
}
public class Mammals extends Animal{
}
public class Birds extends Animal{
}
public class Main{
public static void main(String args[]){
// write your code
}
}
INHERITANCE BY
ANIMAL
Main Program
public class Animal{
eat();
reproduce();
sleep();
}
public class Amphibians extends Animal {
swim();
}
public class Reptiles extends Animal{
crawl();
}
public class Mammals extends Animal{
giveMilk();
}
public class Birds extends Animal {
fly();
}
public class Main{
public static void main (String args[] ){
Amphibians obj1=new Amphibians();
Reptiles obj2=new Reptiles();
Mammals obj3=new Mammals();
Birds obj4=new Birds();
}
}
THANKYOU
Any Suggestion Or Question IsWelcome

More Related Content

What's hot

Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
Pooja Jaiswal
 
Inheritance in java
Inheritance in java Inheritance in java
Inheritance in java
yash jain
 
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 in java
Inheritance in javaInheritance in java
Inheritance in java
RahulAnanda1
 
Inheritance In Java
Inheritance In JavaInheritance In Java
Inheritance In Java
Arnab Bhaumik
 
Classes objects in java
Classes objects in javaClasses objects in java
Classes objects in java
Madishetty Prathibha
 
Interfaces in java
Interfaces in javaInterfaces in java
Interfaces in java
Abishek Purushothaman
 
Java Presentation For Syntax
Java Presentation For SyntaxJava Presentation For Syntax
Java Presentation For Syntax
PravinYalameli
 
Type casting in java
Type casting in javaType casting in java
Type casting in java
Farooq Baloch
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
Pavith Gunasekara
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methods
Shubham Dwivedi
 
Oop java
Oop javaOop java
Oop java
Minal Maniar
 
Oops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in JavaOops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in Java
Madishetty Prathibha
 
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
 
Inheritance In Java
Inheritance In JavaInheritance In Java
Inheritance In Java
Manish Sahu
 
Interface in java
Interface in javaInterface in java
Collections In Java
Collections In JavaCollections In Java
Collections In JavaBinoj T E
 

What's hot (20)

Inheritance
InheritanceInheritance
Inheritance
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
 
Inheritance in java
Inheritance in java Inheritance in java
Inheritance in java
 
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 in java
Inheritance in javaInheritance in java
Inheritance in java
 
Inheritance In Java
Inheritance In JavaInheritance In Java
Inheritance In Java
 
Inheritance C#
Inheritance C#Inheritance C#
Inheritance C#
 
OOP java
OOP javaOOP java
OOP java
 
Classes objects in java
Classes objects in javaClasses objects in java
Classes objects in java
 
Interfaces in java
Interfaces in javaInterfaces in java
Interfaces in java
 
Java Presentation For Syntax
Java Presentation For SyntaxJava Presentation For Syntax
Java Presentation For Syntax
 
Type casting in java
Type casting in javaType casting in java
Type casting in java
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methods
 
Oop java
Oop javaOop java
Oop java
 
Oops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in JavaOops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts 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)
Basic Concepts of OOPs (Object Oriented Programming in Java)
 
Inheritance In Java
Inheritance In JavaInheritance In Java
Inheritance In Java
 
Interface in java
Interface in javaInterface in java
Interface in java
 
Collections In Java
Collections In JavaCollections In Java
Collections In Java
 

Similar to Inheritance In Java

Inheritance
InheritanceInheritance
Inheritance
SangeethaSasi1
 
Inheritance in OOPS
Inheritance in OOPSInheritance in OOPS
Inheritance in OOPS
Ronak Chhajed
 
E -COMMERCE.ppt
E -COMMERCE.pptE -COMMERCE.ppt
E -COMMERCE.ppt
classall
 
Inheritance
InheritanceInheritance
Inheritance
disha singh
 
Java
JavaJava
Inheritance
InheritanceInheritance
Inheritance
prabhat kumar
 
Inheritance ppt
Inheritance pptInheritance ppt
Inheritance ppt
Nivegeetha
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
Ariful Islam
 
Java(inheritance)
Java(inheritance)Java(inheritance)
Java(inheritance)
Pooja Bhojwani
 
Inheritance
InheritanceInheritance
Inheritance
rajshreemuthiah
 
INHERTANCE , NARROW AND WIDENING
INHERTANCE , NARROW AND WIDENING INHERTANCE , NARROW AND WIDENING
INHERTANCE , NARROW AND WIDENING
ManpreetSingh1387
 
Programming Lesson by Slidesgo.pptx
Programming Lesson by Slidesgo.pptxProgramming Lesson by Slidesgo.pptx
Programming Lesson by Slidesgo.pptx
DilanAlmsa
 
lecture 6.pdf
lecture 6.pdflecture 6.pdf
lecture 6.pdf
WaqarRaj1
 
Inheritance OOP Concept in C++.
Inheritance OOP Concept in C++.Inheritance OOP Concept in C++.
Inheritance OOP Concept in C++.
MASQ Technologies
 
Inheritance in Java.pdf
Inheritance in Java.pdfInheritance in Java.pdf
Inheritance in Java.pdf
kumari36
 
All 5 Types of Inheritance in Java | Analytics Jobs
All 5 Types of Inheritance in Java | Analytics JobsAll 5 Types of Inheritance in Java | Analytics Jobs
All 5 Types of Inheritance in Java | Analytics Jobs
AnalyticsJobs
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
HarshitaAshwani
 

Similar to Inheritance In Java (20)

Inheritance
InheritanceInheritance
Inheritance
 
Inheritance in OOPS
Inheritance in OOPSInheritance in OOPS
Inheritance in OOPS
 
E -COMMERCE.ppt
E -COMMERCE.pptE -COMMERCE.ppt
E -COMMERCE.ppt
 
Inheritance
InheritanceInheritance
Inheritance
 
Java
JavaJava
Java
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance ppt
Inheritance pptInheritance ppt
Inheritance ppt
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Java(inheritance)
Java(inheritance)Java(inheritance)
Java(inheritance)
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance
InheritanceInheritance
Inheritance
 
INHERTANCE , NARROW AND WIDENING
INHERTANCE , NARROW AND WIDENING INHERTANCE , NARROW AND WIDENING
INHERTANCE , NARROW AND WIDENING
 
Programming Lesson by Slidesgo.pptx
Programming Lesson by Slidesgo.pptxProgramming Lesson by Slidesgo.pptx
Programming Lesson by Slidesgo.pptx
 
lecture 6.pdf
lecture 6.pdflecture 6.pdf
lecture 6.pdf
 
Inheritance OOP Concept in C++.
Inheritance OOP Concept in C++.Inheritance OOP Concept in C++.
Inheritance OOP Concept in C++.
 
Inheritance in Java.pdf
Inheritance in Java.pdfInheritance in Java.pdf
Inheritance in Java.pdf
 
All 5 Types of Inheritance in Java | Analytics Jobs
All 5 Types of Inheritance in Java | Analytics JobsAll 5 Types of Inheritance in Java | Analytics Jobs
All 5 Types of Inheritance in Java | Analytics Jobs
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 

Recently uploaded

Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
abdulrafaychaudhry
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 

Recently uploaded (20)

Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 

Inheritance In Java

  • 2. Content •What is Inheritance? •Basic Example of Inheritance in Java •Types Of Inheritance •Inheritance By Animal
  • 3. What Is Inheritance? Inheritance in java is a mechanism in which one object acquires all the properties and behaviors of parent object.
  • 4. Inheritance in Java can be best understood in terms of Parent and Child relationship, also known as Super class(Parent) and Sub class(child) in Java language. Inheritance defines a relationship between a Super class and its Sub class. extends and implements keywords are used to describe inheritance in Java
  • 6. //Creating a SubClass class A{ int a=10, b=20; void showab(){ System.out.println(“a: “+a+ “b: ”+b); } } //Creating a SubClass by extanding A class class B extends A{ void sum(){ System.out.println(“Sum of a and b is: ”+(a+b)); } } //Creating Main Class class Main{ public static void main(String args[]){ A obj1= new A(); obj1.showab(); B obj2= new B(); obj2.sum(); } }
  • 8. Inheritance • As you can see, the subclass B include all the members of its super class, A. • This is why class B can access “a” and “b” and call showab(). • Also, include sum(), “a” and “b” can be referred directly, as if they were part of B class. • Even though A is super class for B, it is also a completely independent, stand alone class.
  • 9.
  • 10.
  • 12. TYPES OF INHERITANCE Based on number of ways inheriting the feature of base class into derived class we have some types of inheritance; they are: • Single inheritance • Multilevel inheritance • Hierarchical inheritance
  • 13. SINGLE INHERITANCE When a class extends another one class only then we call it a single inheritance.The below flow diagram shows that class B extends only one class which is A. Here A is a parent class of B and B would be a child class of A
  • 14.
  • 15. MULTIPLE INHERITANCE Here class C inherits class B and class B inherits class A which means B is a parent class of C andA is a parent class of B. So in this case class C is implicitly inheriting the properties and method of class A along with B that’s what is called multilevel inheritance.
  • 16.
  • 17. Hierarchical Inheritance In this inheritance multiple classes inherits from a single class i.e there is one super class and multiple sub classes. As we can see from the below diagram when a same class is having more than one sub class (or) more than one sub class has the same parent is called as Hierarchical Inheritance.
  • 18.
  • 21.
  • 22. SAMPLE PROGRAM public class Animal{ } public class Amphibians extends Animal{ } public class Reptiles extends Animal{ } public class Mammals extends Animal{ } public class Birds extends Animal{ } public class Main{ public static void main(String args[]){ // write your code } }
  • 23.
  • 25. public class Animal{ eat(); reproduce(); sleep(); } public class Amphibians extends Animal { swim(); } public class Reptiles extends Animal{ crawl(); } public class Mammals extends Animal{ giveMilk(); } public class Birds extends Animal { fly(); } public class Main{ public static void main (String args[] ){ Amphibians obj1=new Amphibians(); Reptiles obj2=new Reptiles(); Mammals obj3=new Mammals(); Birds obj4=new Birds(); } }
  • 26. THANKYOU Any Suggestion Or Question IsWelcome