SlideShare a Scribd company logo
1 of 16
Presentation
Polymorphism
Name : Abdul Qayoom
Name: Muhammad Ali
Name:Amar Hussain
Polymorphism
many forms
water forms
Defination
Polymorphism:-
Polymorphism is a greek word meaning "many
forms", and it occurs when we have many classes
that are related to each other by inheritance.
Types Of Polymorphism
There are two types of polymorphism:
1.Compile Time Polymorphism:
2. Run Time Polymorphism:
1.Compile Time Polymorphism:
Compile-time polymorphism is obtained through method overloading.
The term method overloading allows us to have more than one method
with the same name. Since this process is executed during compile
time, that is why it is known as Compile Time Polymorphism.
Method Overloding
1) Same name
2) Same class
3) Different Arguments
Example No:1
class test
{
void show ( int a ) // one argument
{
System.out.println ("1");
}
void show (String b ) // one argument
{
System.out.println ("2");
}
public static void main (String args[])
{
Test t =new Test();
t.show (10);
}
}
OUTPU
T
1
Example No:2
class test
{
void show ( int a , String b) // two arguments
{
System.out.println ("1");
}
void show (String a, int b ) // two arguments
{
System.out.println ("2");
}
public static void main (String args[])
{
Test t =new Test();
t.show (10 , “abc”);
}
}
OUTPU
T
1
What is RunTime Polymorphism
Method overriding is an example of runtime
polymorphism. In method overriding, a subclass overrides
a method with the same signature as that of in its
superclass. During compile time, the check is made on the
reference type.
• When a chlid class extands a parent class the
all of its variable and method is accessible in
the child class. But when the child class
overrides one of the method of the parent class,
then during the runtime the method of child class
is called rather than the parent class, this is
decided in the run time and not in the compile
time.
EXAMPLE
class Animal {
void makesound() {
System.out.println("animal makes a sound");
}
}
class dog extends Animal {
void makesound() {
System.out.println("dog barks");
}
}
class cat extends Animal {
void makesound() {
System.out.println("cat meows");
}
}
public class main {
public static void main(String[] args) {
Animal animal1 = new Dog();
Animal animal2 = new Cat();
animal1.makesound();
animal2.makesound();
}
}
OUTPUT
Dog barks
Cat meows
In this example, both the Dog and Cat classes override the make
Sound method inherited from the Animal class. When you create
instances of Dog and Cat and call the make Sound method on
them, the appropriate overridden method is invoked based on their
actual runtime types.
Thank You

More Related Content

Similar to Presentstion polymorphism opp Java muet u

Polymorphism In Java
Polymorphism In JavaPolymorphism In Java
Polymorphism In JavaSpotle.ai
 
Unit3 inheritance
Unit3 inheritanceUnit3 inheritance
Unit3 inheritanceKalai Selvi
 
Learn java lessons_online
Learn java lessons_onlineLearn java lessons_online
Learn java lessons_onlinenishajj
 
Lecture 6 inheritance
Lecture   6 inheritanceLecture   6 inheritance
Lecture 6 inheritancemanish kumar
 
encapsulation, inheritance, overriding, overloading
encapsulation, inheritance, overriding, overloadingencapsulation, inheritance, overriding, overloading
encapsulation, inheritance, overriding, overloadingShivam Singhal
 
reuse_hiearchies.ppt
reuse_hiearchies.pptreuse_hiearchies.ppt
reuse_hiearchies.pptSohamMathur1
 
Polymorphism in C# Function overloading in C#
Polymorphism in C# Function overloading in C#Polymorphism in C# Function overloading in C#
Polymorphism in C# Function overloading in C#Abid Kohistani
 
06 InheritanceAndPolymorphism.ppt
06 InheritanceAndPolymorphism.ppt06 InheritanceAndPolymorphism.ppt
06 InheritanceAndPolymorphism.pptParikhitGhosh1
 
Pi j3.1 inheritance
Pi j3.1 inheritancePi j3.1 inheritance
Pi j3.1 inheritancemcollison
 
Static and dynamic polymorphism
Static and dynamic polymorphismStatic and dynamic polymorphism
Static and dynamic polymorphismsanjay joshi
 
Chapter 8 Polymorphism
Chapter 8 PolymorphismChapter 8 Polymorphism
Chapter 8 PolymorphismOUM SAOKOSAL
 
Dive into Object Orienter Programming and Design Patterns through java
Dive into Object Orienter Programming and Design Patterns through javaDive into Object Orienter Programming and Design Patterns through java
Dive into Object Orienter Programming and Design Patterns through javaDamith Warnakulasuriya
 
Ppt on this and super keyword
Ppt on this and super keywordPpt on this and super keyword
Ppt on this and super keywordtanu_jaswal
 
Inheritance & Polymorphism
Inheritance & PolymorphismInheritance & Polymorphism
Inheritance & PolymorphismSAGARDAVE29
 
البرمجة الهدفية بلغة جافا - تعدد الأشكال
البرمجة الهدفية بلغة جافا - تعدد الأشكالالبرمجة الهدفية بلغة جافا - تعدد الأشكال
البرمجة الهدفية بلغة جافا - تعدد الأشكالMahmoud Alfarra
 

Similar to Presentstion polymorphism opp Java muet u (20)

Polymorphism In Java
Polymorphism In JavaPolymorphism In Java
Polymorphism In Java
 
Unit3 inheritance
Unit3 inheritanceUnit3 inheritance
Unit3 inheritance
 
Unit3 part2-inheritance
Unit3 part2-inheritanceUnit3 part2-inheritance
Unit3 part2-inheritance
 
Learn java lessons_online
Learn java lessons_onlineLearn java lessons_online
Learn java lessons_online
 
Lecture 6 inheritance
Lecture   6 inheritanceLecture   6 inheritance
Lecture 6 inheritance
 
encapsulation, inheritance, overriding, overloading
encapsulation, inheritance, overriding, overloadingencapsulation, inheritance, overriding, overloading
encapsulation, inheritance, overriding, overloading
 
reuse_hiearchies.ppt
reuse_hiearchies.pptreuse_hiearchies.ppt
reuse_hiearchies.ppt
 
Design patterns(red)
Design patterns(red)Design patterns(red)
Design patterns(red)
 
Polymorphism in C# Function overloading in C#
Polymorphism in C# Function overloading in C#Polymorphism in C# Function overloading in C#
Polymorphism in C# Function overloading in C#
 
Core java oop
Core java oopCore java oop
Core java oop
 
06 InheritanceAndPolymorphism.ppt
06 InheritanceAndPolymorphism.ppt06 InheritanceAndPolymorphism.ppt
06 InheritanceAndPolymorphism.ppt
 
Pi j3.1 inheritance
Pi j3.1 inheritancePi j3.1 inheritance
Pi j3.1 inheritance
 
Static and dynamic polymorphism
Static and dynamic polymorphismStatic and dynamic polymorphism
Static and dynamic polymorphism
 
JAVA_POLYMORPHISM.pptx
JAVA_POLYMORPHISM.pptxJAVA_POLYMORPHISM.pptx
JAVA_POLYMORPHISM.pptx
 
Chapter 8 Polymorphism
Chapter 8 PolymorphismChapter 8 Polymorphism
Chapter 8 Polymorphism
 
Dive into Object Orienter Programming and Design Patterns through java
Dive into Object Orienter Programming and Design Patterns through javaDive into Object Orienter Programming and Design Patterns through java
Dive into Object Orienter Programming and Design Patterns through java
 
Ppt on this and super keyword
Ppt on this and super keywordPpt on this and super keyword
Ppt on this and super keyword
 
Inheritance & Polymorphism
Inheritance & PolymorphismInheritance & Polymorphism
Inheritance & Polymorphism
 
Ppt on java basics
Ppt on java basicsPpt on java basics
Ppt on java basics
 
البرمجة الهدفية بلغة جافا - تعدد الأشكال
البرمجة الهدفية بلغة جافا - تعدد الأشكالالبرمجة الهدفية بلغة جافا - تعدد الأشكال
البرمجة الهدفية بلغة جافا - تعدد الأشكال
 

More from Anjali127411

Engineering management ,notes PPT slides
Engineering management ,notes PPT slidesEngineering management ,notes PPT slides
Engineering management ,notes PPT slidesAnjali127411
 
6qh6iyoesuitvyv0exyn-signature-c0a664d80fc39ee9e26afe9aaa4fdd53cac2536d6a0ca7...
6qh6iyoesuitvyv0exyn-signature-c0a664d80fc39ee9e26afe9aaa4fdd53cac2536d6a0ca7...6qh6iyoesuitvyv0exyn-signature-c0a664d80fc39ee9e26afe9aaa4fdd53cac2536d6a0ca7...
6qh6iyoesuitvyv0exyn-signature-c0a664d80fc39ee9e26afe9aaa4fdd53cac2536d6a0ca7...Anjali127411
 
11-ScriptsAndConditionals.ppt
11-ScriptsAndConditionals.ppt11-ScriptsAndConditionals.ppt
11-ScriptsAndConditionals.pptAnjali127411
 
Presentation ethics
Presentation ethics Presentation ethics
Presentation ethics Anjali127411
 

More from Anjali127411 (6)

Engineering management ,notes PPT slides
Engineering management ,notes PPT slidesEngineering management ,notes PPT slides
Engineering management ,notes PPT slides
 
6qh6iyoesuitvyv0exyn-signature-c0a664d80fc39ee9e26afe9aaa4fdd53cac2536d6a0ca7...
6qh6iyoesuitvyv0exyn-signature-c0a664d80fc39ee9e26afe9aaa4fdd53cac2536d6a0ca7...6qh6iyoesuitvyv0exyn-signature-c0a664d80fc39ee9e26afe9aaa4fdd53cac2536d6a0ca7...
6qh6iyoesuitvyv0exyn-signature-c0a664d80fc39ee9e26afe9aaa4fdd53cac2536d6a0ca7...
 
11-ScriptsAndConditionals.ppt
11-ScriptsAndConditionals.ppt11-ScriptsAndConditionals.ppt
11-ScriptsAndConditionals.ppt
 
Lec11cgu_10.ppt
Lec11cgu_10.pptLec11cgu_10.ppt
Lec11cgu_10.ppt
 
slides03.ppt
slides03.pptslides03.ppt
slides03.ppt
 
Presentation ethics
Presentation ethics Presentation ethics
Presentation ethics
 

Recently uploaded

AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...Gary Wood
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxCeline George
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSAnaAcapella
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxLimon Prince
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesAmanpreetKaur157993
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi RajagopalEADTU
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppCeline George
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismDabee Kamal
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital ManagementMBA Assignment Experts
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17Celine George
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnershipsexpandedwebsite
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSean M. Fox
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjMohammed Sikander
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportDenish Jangid
 

Recently uploaded (20)

AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 

Presentstion polymorphism opp Java muet u

  • 1. Presentation Polymorphism Name : Abdul Qayoom Name: Muhammad Ali Name:Amar Hussain
  • 4.
  • 5.
  • 6. Defination Polymorphism:- Polymorphism is a greek word meaning "many forms", and it occurs when we have many classes that are related to each other by inheritance.
  • 7. Types Of Polymorphism There are two types of polymorphism: 1.Compile Time Polymorphism: 2. Run Time Polymorphism:
  • 8. 1.Compile Time Polymorphism: Compile-time polymorphism is obtained through method overloading. The term method overloading allows us to have more than one method with the same name. Since this process is executed during compile time, that is why it is known as Compile Time Polymorphism.
  • 9. Method Overloding 1) Same name 2) Same class 3) Different Arguments
  • 10. Example No:1 class test { void show ( int a ) // one argument { System.out.println ("1"); } void show (String b ) // one argument { System.out.println ("2"); } public static void main (String args[]) { Test t =new Test(); t.show (10); } } OUTPU T 1
  • 11. Example No:2 class test { void show ( int a , String b) // two arguments { System.out.println ("1"); } void show (String a, int b ) // two arguments { System.out.println ("2"); } public static void main (String args[]) { Test t =new Test(); t.show (10 , “abc”); } } OUTPU T 1
  • 12. What is RunTime Polymorphism Method overriding is an example of runtime polymorphism. In method overriding, a subclass overrides a method with the same signature as that of in its superclass. During compile time, the check is made on the reference type.
  • 13. • When a chlid class extands a parent class the all of its variable and method is accessible in the child class. But when the child class overrides one of the method of the parent class, then during the runtime the method of child class is called rather than the parent class, this is decided in the run time and not in the compile time.
  • 14. EXAMPLE class Animal { void makesound() { System.out.println("animal makes a sound"); } } class dog extends Animal { void makesound() { System.out.println("dog barks"); } } class cat extends Animal { void makesound() { System.out.println("cat meows"); } } public class main { public static void main(String[] args) { Animal animal1 = new Dog(); Animal animal2 = new Cat(); animal1.makesound(); animal2.makesound(); } } OUTPUT Dog barks Cat meows
  • 15. In this example, both the Dog and Cat classes override the make Sound method inherited from the Animal class. When you create instances of Dog and Cat and call the make Sound method on them, the appropriate overridden method is invoked based on their actual runtime types.