SlideShare a Scribd company logo
M.Rajshree
II-MSC(IT)
Nadar saraswathi college of arts&science
Polymorphism is the ability of a message to
be displayed in more than one form
 The most common use of polymorphism in
OOP occurs when a parent class reference is
used to refer to a child class object.
Any Java object that can pass more than one a
test is considered to be polymorphic
Create a completely separate class specific to
each type of object
These object classes would share a lot of
members in common, but they would be
completely separate from each other
for example, that had the generic object
members such as the speed property and the
travel method
There is another object oriented
Programming concept that is closely related
to abstract classes called interface
Interfaces allow us to define polymorphism
in a declarative way unrelated to
implementation
In interfaces, you can only define (not
implement) methods inside the parent class
Use the concept of an Interface class that will
define (but will not implement) common
properties and methods for the more specific
classes
Create separate classes then implement each
specific type of object that you will need
And that use the interface class to specify
common functionality
 The classes that implement the Interface must
implement all members of the Interface
 An Interface is a class that has only a method
body but no implementation
Example:
public interface shape
{
void draw();
}
Shape is an interface with only one method,
i.e. draw(). Basically, it is a contract that when
you are implementing that interface, you have
to implement the draw functionality, or else
you are not a complete class
 So for any class like Triangle or Rectangle,
when we implement that Interface, they must
implement the draw() method
 We sometimes use an arraylist, we are not as
concerned about how the feature set by the list
interface have been implemented by arraylist
Example :
List l = New ArrayList();
l.add()
 we needed to use an LinkedList instead of
an ArrayList, we could easily do that by changing:
List l = new LinkedList();
 ArrayList used in our program because we used
them through the contract published by the Interface
 The methods cannot be implemented inside the
interface
 Variables (properties) cannot be defined inside the
interface
 All the methods defined inside the interface need to
be implemented in the child class
 All the necessary variables need to be defined
inside the child class
 Man interface enforces its implementing classes to
implement all the methods in the interface
 Implementation interfaces, there are several
rules a class can implement more than
one interface at a time
A class can extend only one class but it
implement many interfaces
An interface can extend another interface in
a similar way as a class can extend another
class
Thank you

More Related Content

PDF
Interface
Shantilal Bhayal
 
DOCX
C# concepts
lexilijoseph
 
PPTX
Abstract Class Presentation
tigerwarn
 
PDF
Lecture 10
Debasish Pratihari
 
PPTX
Java interfaces
jehan1987
 
PPT
Core Java interview questions-ppt
Mayank Kumar
 
DOC
116824015 java-j2 ee
homeworkping9
 
Interface
Shantilal Bhayal
 
C# concepts
lexilijoseph
 
Abstract Class Presentation
tigerwarn
 
Lecture 10
Debasish Pratihari
 
Java interfaces
jehan1987
 
Core Java interview questions-ppt
Mayank Kumar
 
116824015 java-j2 ee
homeworkping9
 

What's hot (19)

PPTX
Lecture 18
talha ijaz
 
PDF
Java OOP Programming language (Part 6) - Abstract Class & Interface
OUM SAOKOSAL
 
PPTX
QSpiders - Major difference
Qspiders - Software Testing Training Institute
 
PPTX
Top 20 c# interview Question and answers
w3asp dotnet
 
DOCX
Java interface
HoneyChintal
 
PDF
Object Oriented Principles
Sujit Majety
 
DOCX
C# question answers
application developer
 
PPTX
Java presentation
Akteruzzaman .
 
PPT
Interface in java By Dheeraj Kumar Singh
dheeraj_cse
 
PPT
Chapter 9 Interface
OUM SAOKOSAL
 
PPTX
Object Orinted Programing(OOP) concepts \
Pritom Chaki
 
PPT
Chapter 03
Graham Royce
 
PDF
Inheritance
Ravi_Kant_Sahu
 
PPTX
Interfaces in java
Abishek Purushothaman
 
PDF
Data Structure Interview Questions & Answers
Satyam Jaiswal
 
PPT
Interfaces
myrajendra
 
PPTX
Object Oriented Programming - Basic Concepts
Arunkumar Kupppuswamy
 
PPTX
object oriented programing lecture 1
Geophery sanga
 
Lecture 18
talha ijaz
 
Java OOP Programming language (Part 6) - Abstract Class & Interface
OUM SAOKOSAL
 
Top 20 c# interview Question and answers
w3asp dotnet
 
Java interface
HoneyChintal
 
Object Oriented Principles
Sujit Majety
 
C# question answers
application developer
 
Java presentation
Akteruzzaman .
 
Interface in java By Dheeraj Kumar Singh
dheeraj_cse
 
Chapter 9 Interface
OUM SAOKOSAL
 
Object Orinted Programing(OOP) concepts \
Pritom Chaki
 
Chapter 03
Graham Royce
 
Inheritance
Ravi_Kant_Sahu
 
Interfaces in java
Abishek Purushothaman
 
Data Structure Interview Questions & Answers
Satyam Jaiswal
 
Interfaces
myrajendra
 
Object Oriented Programming - Basic Concepts
Arunkumar Kupppuswamy
 
object oriented programing lecture 1
Geophery sanga
 
Ad

Similar to Implementing polymorphism (20)

PPT
Interfaces.ppt
VarunP31
 
PPT
Interfaces .ppt
AsifMulani17
 
PPT
Java interfaces & abstract classes
Shreyans Pathak
 
PPTX
Object Oriented Programming - Polymorphism and Interfaces
Habtamu Wolde
 
PPT
Java interfaces
Raja Sekhar
 
DOCX
Core java questions
Pradheep Ayyanar
 
PPTX
Java 6.pptx
usmanusman720379
 
PPT
Opps
Lalit Kale
 
PPTX
Abstraction encapsulation inheritance polymorphism
PriyadharshiniG41
 
PDF
Pocket java
Kumaran K
 
PPT
Unit 1 Java
arnold 7490
 
PDF
oopsinvb-191021101327.pdf
JP Chicano
 
PPTX
Oops in vb
Dalwin INDIA
 
PDF
What are abstract classes Dont interfaces also allow for polymo.pdf
arihantkitchenmart
 
PPT
Interfaces
RBIEBT,MOHALI
 
PPTX
Object Oriented Programing JAVA presentaion
Pritom Chaki
 
PPTX
Basic concept of class, method , command line-argument
Suresh Mohta
 
PDF
JAVA-PPT'S.pdf
AnmolVerma363503
 
TXT
Java interview
Mohammad Shahban
 
Interfaces.ppt
VarunP31
 
Interfaces .ppt
AsifMulani17
 
Java interfaces & abstract classes
Shreyans Pathak
 
Object Oriented Programming - Polymorphism and Interfaces
Habtamu Wolde
 
Java interfaces
Raja Sekhar
 
Core java questions
Pradheep Ayyanar
 
Java 6.pptx
usmanusman720379
 
Abstraction encapsulation inheritance polymorphism
PriyadharshiniG41
 
Pocket java
Kumaran K
 
Unit 1 Java
arnold 7490
 
oopsinvb-191021101327.pdf
JP Chicano
 
Oops in vb
Dalwin INDIA
 
What are abstract classes Dont interfaces also allow for polymo.pdf
arihantkitchenmart
 
Interfaces
RBIEBT,MOHALI
 
Object Oriented Programing JAVA presentaion
Pritom Chaki
 
Basic concept of class, method , command line-argument
Suresh Mohta
 
JAVA-PPT'S.pdf
AnmolVerma363503
 
Java interview
Mohammad Shahban
 
Ad

More from rajshreemuthiah (20)

PPTX
oracle
rajshreemuthiah
 
PPTX
quality
rajshreemuthiah
 
PPTX
bigdata
rajshreemuthiah
 
PPTX
polymorphism
rajshreemuthiah
 
PPTX
solutions and understanding text analytics
rajshreemuthiah
 
PPTX
interface
rajshreemuthiah
 
PPTX
Testing &ampdebugging
rajshreemuthiah
 
PPTX
concurrency control
rajshreemuthiah
 
PPTX
Education
rajshreemuthiah
 
PPTX
Formal verification
rajshreemuthiah
 
PPTX
Transaction management
rajshreemuthiah
 
PPTX
Multi thread
rajshreemuthiah
 
PPTX
System testing
rajshreemuthiah
 
PPTX
software maintenance
rajshreemuthiah
 
PPTX
exception handling
rajshreemuthiah
 
PPTX
e governance
rajshreemuthiah
 
PPTX
recovery management
rajshreemuthiah
 
PPSX
Buffer managements
rajshreemuthiah
 
PPTX
os linux
rajshreemuthiah
 
PPTX
Ipv4
rajshreemuthiah
 
polymorphism
rajshreemuthiah
 
solutions and understanding text analytics
rajshreemuthiah
 
interface
rajshreemuthiah
 
Testing &ampdebugging
rajshreemuthiah
 
concurrency control
rajshreemuthiah
 
Education
rajshreemuthiah
 
Formal verification
rajshreemuthiah
 
Transaction management
rajshreemuthiah
 
Multi thread
rajshreemuthiah
 
System testing
rajshreemuthiah
 
software maintenance
rajshreemuthiah
 
exception handling
rajshreemuthiah
 
e governance
rajshreemuthiah
 
recovery management
rajshreemuthiah
 
Buffer managements
rajshreemuthiah
 
os linux
rajshreemuthiah
 

Recently uploaded (20)

PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PDF
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PDF
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PPTX
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 

Implementing polymorphism

  • 2. Polymorphism is the ability of a message to be displayed in more than one form  The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object. Any Java object that can pass more than one a test is considered to be polymorphic
  • 3. Create a completely separate class specific to each type of object These object classes would share a lot of members in common, but they would be completely separate from each other for example, that had the generic object members such as the speed property and the travel method
  • 4. There is another object oriented Programming concept that is closely related to abstract classes called interface Interfaces allow us to define polymorphism in a declarative way unrelated to implementation In interfaces, you can only define (not implement) methods inside the parent class
  • 5. Use the concept of an Interface class that will define (but will not implement) common properties and methods for the more specific classes Create separate classes then implement each specific type of object that you will need And that use the interface class to specify common functionality
  • 6.  The classes that implement the Interface must implement all members of the Interface  An Interface is a class that has only a method body but no implementation Example: public interface shape { void draw(); }
  • 7. Shape is an interface with only one method, i.e. draw(). Basically, it is a contract that when you are implementing that interface, you have to implement the draw functionality, or else you are not a complete class  So for any class like Triangle or Rectangle, when we implement that Interface, they must implement the draw() method
  • 8.  We sometimes use an arraylist, we are not as concerned about how the feature set by the list interface have been implemented by arraylist Example : List l = New ArrayList(); l.add()  we needed to use an LinkedList instead of an ArrayList, we could easily do that by changing: List l = new LinkedList();  ArrayList used in our program because we used them through the contract published by the Interface
  • 9.  The methods cannot be implemented inside the interface  Variables (properties) cannot be defined inside the interface  All the methods defined inside the interface need to be implemented in the child class  All the necessary variables need to be defined inside the child class  Man interface enforces its implementing classes to implement all the methods in the interface
  • 10.  Implementation interfaces, there are several rules a class can implement more than one interface at a time A class can extend only one class but it implement many interfaces An interface can extend another interface in a similar way as a class can extend another class