尊敬的 微信汇率:1円 ≈ 0.046166 元 支付宝汇率:1円 ≈ 0.046257元 [退出登录]
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

What's hot

Lecture 18
Lecture 18Lecture 18
Lecture 18
talha ijaz
 
Java OOP Programming language (Part 6) - Abstract Class & Interface
Java OOP Programming language (Part 6) - Abstract Class & InterfaceJava OOP Programming language (Part 6) - Abstract Class & Interface
Java OOP Programming language (Part 6) - Abstract Class & Interface
OUM SAOKOSAL
 
QSpiders - Major difference
QSpiders - Major differenceQSpiders - Major difference
Top 20 c# interview Question and answers
Top 20 c# interview Question and answersTop 20 c# interview Question and answers
Top 20 c# interview Question and answers
w3asp dotnet
 
Java interface
Java interface Java interface
Java interface
HoneyChintal
 
Object Oriented Principles
Object Oriented PrinciplesObject Oriented Principles
Object Oriented Principles
Sujit Majety
 
Assigment 2
Assigment 2Assigment 2
C# question answers
C# question answersC# question answers
C# question answers
application developer
 
Java presentation
Java presentationJava presentation
Java presentation
Akteruzzaman .
 
Interface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar SinghInterface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar Singh
dheeraj_cse
 
Chapter 9 Interface
Chapter 9 InterfaceChapter 9 Interface
Chapter 9 Interface
OUM SAOKOSAL
 
Object Orinted Programing(OOP) concepts \
Object Orinted Programing(OOP) concepts \Object Orinted Programing(OOP) concepts \
Object Orinted Programing(OOP) concepts \
Pritom Chaki
 
Chapter 03
Chapter 03Chapter 03
Chapter 03
Graham Royce
 
Inheritance
InheritanceInheritance
Inheritance
Ravi_Kant_Sahu
 
Interfaces in java
Interfaces in javaInterfaces in java
Interfaces in java
Abishek Purushothaman
 
Data Structure Interview Questions & Answers
Data Structure Interview Questions & AnswersData Structure Interview Questions & Answers
Data Structure Interview Questions & Answers
Satyam Jaiswal
 
Interfaces
InterfacesInterfaces
Interfaces
myrajendra
 
Object Oriented Programming - Basic Concepts
Object Oriented Programming - Basic ConceptsObject Oriented Programming - Basic Concepts
Object Oriented Programming - Basic Concepts
Arunkumar Kupppuswamy
 
object oriented programing lecture 1
object oriented programing lecture 1object oriented programing lecture 1
object oriented programing lecture 1
Geophery sanga
 

What's hot (19)

Lecture 18
Lecture 18Lecture 18
Lecture 18
 
Java OOP Programming language (Part 6) - Abstract Class & Interface
Java OOP Programming language (Part 6) - Abstract Class & InterfaceJava OOP Programming language (Part 6) - Abstract Class & Interface
Java OOP Programming language (Part 6) - Abstract Class & Interface
 
QSpiders - Major difference
QSpiders - Major differenceQSpiders - Major difference
QSpiders - Major difference
 
Top 20 c# interview Question and answers
Top 20 c# interview Question and answersTop 20 c# interview Question and answers
Top 20 c# interview Question and answers
 
Java interface
Java interface Java interface
Java interface
 
Object Oriented Principles
Object Oriented PrinciplesObject Oriented Principles
Object Oriented Principles
 
Assigment 2
Assigment 2Assigment 2
Assigment 2
 
C# question answers
C# question answersC# question answers
C# question answers
 
Java presentation
Java presentationJava presentation
Java presentation
 
Interface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar SinghInterface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar Singh
 
Chapter 9 Interface
Chapter 9 InterfaceChapter 9 Interface
Chapter 9 Interface
 
Object Orinted Programing(OOP) concepts \
Object Orinted Programing(OOP) concepts \Object Orinted Programing(OOP) concepts \
Object Orinted Programing(OOP) concepts \
 
Chapter 03
Chapter 03Chapter 03
Chapter 03
 
Inheritance
InheritanceInheritance
Inheritance
 
Interfaces in java
Interfaces in javaInterfaces in java
Interfaces in java
 
Data Structure Interview Questions & Answers
Data Structure Interview Questions & AnswersData Structure Interview Questions & Answers
Data Structure Interview Questions & Answers
 
Interfaces
InterfacesInterfaces
Interfaces
 
Object Oriented Programming - Basic Concepts
Object Oriented Programming - Basic ConceptsObject Oriented Programming - Basic Concepts
Object Oriented Programming - Basic Concepts
 
object oriented programing lecture 1
object oriented programing lecture 1object oriented programing lecture 1
object oriented programing lecture 1
 

Similar to Implementing polymorphism

Interfaces .ppt
Interfaces .pptInterfaces .ppt
Interfaces .ppt
AsifMulani17
 
Interfaces.ppt
Interfaces.pptInterfaces.ppt
Interfaces.ppt
VarunP31
 
Java interfaces & abstract classes
Java interfaces & abstract classesJava interfaces & abstract classes
Java interfaces & abstract classes
Shreyans Pathak
 
Object Oriented Programming - Polymorphism and Interfaces
Object Oriented Programming - Polymorphism and InterfacesObject Oriented Programming - Polymorphism and Interfaces
Object Oriented Programming - Polymorphism and Interfaces
Habtamu Wolde
 
C# program structure
C# program structureC# program structure
Java interfaces
Java interfacesJava interfaces
Java interfaces
Raja Sekhar
 
Core java questions
Core java questionsCore java questions
Core java questions
Pradheep Ayyanar
 
Java 6.pptx
Java 6.pptxJava 6.pptx
Java 6.pptx
usmanusman720379
 
Opps
OppsOpps
Pocket java
Pocket javaPocket java
Pocket java
Kumaran K
 
Unit 1 Java
Unit 1 JavaUnit 1 Java
Unit 1 Java
arnold 7490
 
oopsinvb-191021101327.pdf
oopsinvb-191021101327.pdfoopsinvb-191021101327.pdf
oopsinvb-191021101327.pdf
JP Chicano
 
Oops in vb
Oops in vbOops in vb
Oops in vb
Dalwin INDIA
 
What are abstract classes Dont interfaces also allow for polymo.pdf
What are abstract classes Dont interfaces also allow for polymo.pdfWhat are abstract classes Dont interfaces also allow for polymo.pdf
What are abstract classes Dont interfaces also allow for polymo.pdf
arihantkitchenmart
 
Interfaces
InterfacesInterfaces
Interfaces
RBIEBT,MOHALI
 
Object Oriented Programing JAVA presentaion
Object Oriented Programing JAVA presentaionObject Oriented Programing JAVA presentaion
Object Oriented Programing JAVA presentaion
Pritom Chaki
 
Basic concept of class, method , command line-argument
Basic concept of class, method , command line-argumentBasic concept of class, method , command line-argument
Basic concept of class, method , command line-argument
Suresh Mohta
 
JAVA-PPT'S.pdf
JAVA-PPT'S.pdfJAVA-PPT'S.pdf
JAVA-PPT'S.pdf
AnmolVerma363503
 
Java interview
Java interviewJava interview
Java interview
Mohammad Shahban
 
Java mcq
Java mcqJava mcq
Java mcq
avinash9821
 

Similar to Implementing polymorphism (20)

Interfaces .ppt
Interfaces .pptInterfaces .ppt
Interfaces .ppt
 
Interfaces.ppt
Interfaces.pptInterfaces.ppt
Interfaces.ppt
 
Java interfaces & abstract classes
Java interfaces & abstract classesJava interfaces & abstract classes
Java interfaces & abstract classes
 
Object Oriented Programming - Polymorphism and Interfaces
Object Oriented Programming - Polymorphism and InterfacesObject Oriented Programming - Polymorphism and Interfaces
Object Oriented Programming - Polymorphism and Interfaces
 
C# program structure
C# program structureC# program structure
C# program structure
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
 
Core java questions
Core java questionsCore java questions
Core java questions
 
Java 6.pptx
Java 6.pptxJava 6.pptx
Java 6.pptx
 
Opps
OppsOpps
Opps
 
Pocket java
Pocket javaPocket java
Pocket java
 
Unit 1 Java
Unit 1 JavaUnit 1 Java
Unit 1 Java
 
oopsinvb-191021101327.pdf
oopsinvb-191021101327.pdfoopsinvb-191021101327.pdf
oopsinvb-191021101327.pdf
 
Oops in vb
Oops in vbOops in vb
Oops in vb
 
What are abstract classes Dont interfaces also allow for polymo.pdf
What are abstract classes Dont interfaces also allow for polymo.pdfWhat are abstract classes Dont interfaces also allow for polymo.pdf
What are abstract classes Dont interfaces also allow for polymo.pdf
 
Interfaces
InterfacesInterfaces
Interfaces
 
Object Oriented Programing JAVA presentaion
Object Oriented Programing JAVA presentaionObject Oriented Programing JAVA presentaion
Object Oriented Programing JAVA presentaion
 
Basic concept of class, method , command line-argument
Basic concept of class, method , command line-argumentBasic concept of class, method , command line-argument
Basic concept of class, method , command line-argument
 
JAVA-PPT'S.pdf
JAVA-PPT'S.pdfJAVA-PPT'S.pdf
JAVA-PPT'S.pdf
 
Java interview
Java interviewJava interview
Java interview
 
Java mcq
Java mcqJava mcq
Java mcq
 

More from rajshreemuthiah

oracle
oracleoracle
quality
qualityquality
bigdata
bigdatabigdata
polymorphism
polymorphismpolymorphism
polymorphism
rajshreemuthiah
 
solutions and understanding text analytics
solutions and understanding text analyticssolutions and understanding text analytics
solutions and understanding text analytics
rajshreemuthiah
 
interface
interfaceinterface
interface
rajshreemuthiah
 
Testing &ampdebugging
Testing &ampdebuggingTesting &ampdebugging
Testing &ampdebugging
rajshreemuthiah
 
concurrency control
concurrency controlconcurrency control
concurrency control
rajshreemuthiah
 
Education
EducationEducation
Education
rajshreemuthiah
 
Formal verification
Formal verificationFormal verification
Formal verification
rajshreemuthiah
 
Transaction management
Transaction management Transaction management
Transaction management
rajshreemuthiah
 
Multi thread
Multi threadMulti thread
Multi thread
rajshreemuthiah
 
System testing
System testingSystem testing
System testing
rajshreemuthiah
 
software maintenance
software maintenancesoftware maintenance
software maintenance
rajshreemuthiah
 
exception handling
exception handlingexception handling
exception handling
rajshreemuthiah
 
e governance
e governancee governance
e governance
rajshreemuthiah
 
recovery management
recovery managementrecovery management
recovery management
rajshreemuthiah
 
Buffer managements
Buffer managementsBuffer managements
Buffer managements
rajshreemuthiah
 
os linux
os linuxos linux
os linux
rajshreemuthiah
 
Ipv4
Ipv4Ipv4

More from rajshreemuthiah (20)

oracle
oracleoracle
oracle
 
quality
qualityquality
quality
 
bigdata
bigdatabigdata
bigdata
 
polymorphism
polymorphismpolymorphism
polymorphism
 
solutions and understanding text analytics
solutions and understanding text analyticssolutions and understanding text analytics
solutions and understanding text analytics
 
interface
interfaceinterface
interface
 
Testing &ampdebugging
Testing &ampdebuggingTesting &ampdebugging
Testing &ampdebugging
 
concurrency control
concurrency controlconcurrency control
concurrency control
 
Education
EducationEducation
Education
 
Formal verification
Formal verificationFormal verification
Formal verification
 
Transaction management
Transaction management Transaction management
Transaction management
 
Multi thread
Multi threadMulti thread
Multi thread
 
System testing
System testingSystem testing
System testing
 
software maintenance
software maintenancesoftware maintenance
software maintenance
 
exception handling
exception handlingexception handling
exception handling
 
e governance
e governancee governance
e governance
 
recovery management
recovery managementrecovery management
recovery management
 
Buffer managements
Buffer managementsBuffer managements
Buffer managements
 
os linux
os linuxos linux
os linux
 
Ipv4
Ipv4Ipv4
Ipv4
 

Recently uploaded

An Introduction to All Data Enterprise Integration
An Introduction to All Data Enterprise IntegrationAn Introduction to All Data Enterprise Integration
An Introduction to All Data Enterprise Integration
Safe Software
 
Fuxnet [EN] .pdf
Fuxnet [EN]                                   .pdfFuxnet [EN]                                   .pdf
Fuxnet [EN] .pdf
Overkill Security
 
ScyllaDB Leaps Forward with Dor Laor, CEO of ScyllaDB
ScyllaDB Leaps Forward with Dor Laor, CEO of ScyllaDBScyllaDB Leaps Forward with Dor Laor, CEO of ScyllaDB
ScyllaDB Leaps Forward with Dor Laor, CEO of ScyllaDB
ScyllaDB
 
MongoDB to ScyllaDB: Technical Comparison and the Path to Success
MongoDB to ScyllaDB: Technical Comparison and the Path to SuccessMongoDB to ScyllaDB: Technical Comparison and the Path to Success
MongoDB to ScyllaDB: Technical Comparison and the Path to Success
ScyllaDB
 
MongoDB vs ScyllaDB: Tractian’s Experience with Real-Time ML
MongoDB vs ScyllaDB: Tractian’s Experience with Real-Time MLMongoDB vs ScyllaDB: Tractian’s Experience with Real-Time ML
MongoDB vs ScyllaDB: Tractian’s Experience with Real-Time ML
ScyllaDB
 
Elasticity vs. State? Exploring Kafka Streams Cassandra State Store
Elasticity vs. State? Exploring Kafka Streams Cassandra State StoreElasticity vs. State? Exploring Kafka Streams Cassandra State Store
Elasticity vs. State? Exploring Kafka Streams Cassandra State Store
ScyllaDB
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
UiPathCommunity
 
Introducing BoxLang : A new JVM language for productivity and modularity!
Introducing BoxLang : A new JVM language for productivity and modularity!Introducing BoxLang : A new JVM language for productivity and modularity!
Introducing BoxLang : A new JVM language for productivity and modularity!
Ortus Solutions, Corp
 
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeckPoznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
FilipTomaszewski5
 
Radically Outperforming DynamoDB @ Digital Turbine with SADA and Google Cloud
Radically Outperforming DynamoDB @ Digital Turbine with SADA and Google CloudRadically Outperforming DynamoDB @ Digital Turbine with SADA and Google Cloud
Radically Outperforming DynamoDB @ Digital Turbine with SADA and Google Cloud
ScyllaDB
 
ThousandEyes New Product Features and Release Highlights: June 2024
ThousandEyes New Product Features and Release Highlights: June 2024ThousandEyes New Product Features and Release Highlights: June 2024
ThousandEyes New Product Features and Release Highlights: June 2024
ThousandEyes
 
Day 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio FundamentalsDay 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio Fundamentals
UiPathCommunity
 
ScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking ReplicationScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking Replication
ScyllaDB
 
Call Girls Chennai ☎️ +91-7426014248 😍 Chennai Call Girl Beauty Girls Chennai...
Call Girls Chennai ☎️ +91-7426014248 😍 Chennai Call Girl Beauty Girls Chennai...Call Girls Chennai ☎️ +91-7426014248 😍 Chennai Call Girl Beauty Girls Chennai...
Call Girls Chennai ☎️ +91-7426014248 😍 Chennai Call Girl Beauty Girls Chennai...
anilsa9823
 
From NCSA to the National Research Platform
From NCSA to the National Research PlatformFrom NCSA to the National Research Platform
From NCSA to the National Research Platform
Larry Smarr
 
Automation Student Developers Session 3: Introduction to UI Automation
Automation Student Developers Session 3: Introduction to UI AutomationAutomation Student Developers Session 3: Introduction to UI Automation
Automation Student Developers Session 3: Introduction to UI Automation
UiPathCommunity
 
CNSCon 2024 Lightning Talk: Don’t Make Me Impersonate My Identity
CNSCon 2024 Lightning Talk: Don’t Make Me Impersonate My IdentityCNSCon 2024 Lightning Talk: Don’t Make Me Impersonate My Identity
CNSCon 2024 Lightning Talk: Don’t Make Me Impersonate My Identity
Cynthia Thomas
 
So You've Lost Quorum: Lessons From Accidental Downtime
So You've Lost Quorum: Lessons From Accidental DowntimeSo You've Lost Quorum: Lessons From Accidental Downtime
So You've Lost Quorum: Lessons From Accidental Downtime
ScyllaDB
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
Pablo Gómez Abajo
 
Containers & AI - Beauty and the Beast!?!
Containers & AI - Beauty and the Beast!?!Containers & AI - Beauty and the Beast!?!
Containers & AI - Beauty and the Beast!?!
Tobias Schneck
 

Recently uploaded (20)

An Introduction to All Data Enterprise Integration
An Introduction to All Data Enterprise IntegrationAn Introduction to All Data Enterprise Integration
An Introduction to All Data Enterprise Integration
 
Fuxnet [EN] .pdf
Fuxnet [EN]                                   .pdfFuxnet [EN]                                   .pdf
Fuxnet [EN] .pdf
 
ScyllaDB Leaps Forward with Dor Laor, CEO of ScyllaDB
ScyllaDB Leaps Forward with Dor Laor, CEO of ScyllaDBScyllaDB Leaps Forward with Dor Laor, CEO of ScyllaDB
ScyllaDB Leaps Forward with Dor Laor, CEO of ScyllaDB
 
MongoDB to ScyllaDB: Technical Comparison and the Path to Success
MongoDB to ScyllaDB: Technical Comparison and the Path to SuccessMongoDB to ScyllaDB: Technical Comparison and the Path to Success
MongoDB to ScyllaDB: Technical Comparison and the Path to Success
 
MongoDB vs ScyllaDB: Tractian’s Experience with Real-Time ML
MongoDB vs ScyllaDB: Tractian’s Experience with Real-Time MLMongoDB vs ScyllaDB: Tractian’s Experience with Real-Time ML
MongoDB vs ScyllaDB: Tractian’s Experience with Real-Time ML
 
Elasticity vs. State? Exploring Kafka Streams Cassandra State Store
Elasticity vs. State? Exploring Kafka Streams Cassandra State StoreElasticity vs. State? Exploring Kafka Streams Cassandra State Store
Elasticity vs. State? Exploring Kafka Streams Cassandra State Store
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
 
Introducing BoxLang : A new JVM language for productivity and modularity!
Introducing BoxLang : A new JVM language for productivity and modularity!Introducing BoxLang : A new JVM language for productivity and modularity!
Introducing BoxLang : A new JVM language for productivity and modularity!
 
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeckPoznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
 
Radically Outperforming DynamoDB @ Digital Turbine with SADA and Google Cloud
Radically Outperforming DynamoDB @ Digital Turbine with SADA and Google CloudRadically Outperforming DynamoDB @ Digital Turbine with SADA and Google Cloud
Radically Outperforming DynamoDB @ Digital Turbine with SADA and Google Cloud
 
ThousandEyes New Product Features and Release Highlights: June 2024
ThousandEyes New Product Features and Release Highlights: June 2024ThousandEyes New Product Features and Release Highlights: June 2024
ThousandEyes New Product Features and Release Highlights: June 2024
 
Day 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio FundamentalsDay 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio Fundamentals
 
ScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking ReplicationScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking Replication
 
Call Girls Chennai ☎️ +91-7426014248 😍 Chennai Call Girl Beauty Girls Chennai...
Call Girls Chennai ☎️ +91-7426014248 😍 Chennai Call Girl Beauty Girls Chennai...Call Girls Chennai ☎️ +91-7426014248 😍 Chennai Call Girl Beauty Girls Chennai...
Call Girls Chennai ☎️ +91-7426014248 😍 Chennai Call Girl Beauty Girls Chennai...
 
From NCSA to the National Research Platform
From NCSA to the National Research PlatformFrom NCSA to the National Research Platform
From NCSA to the National Research Platform
 
Automation Student Developers Session 3: Introduction to UI Automation
Automation Student Developers Session 3: Introduction to UI AutomationAutomation Student Developers Session 3: Introduction to UI Automation
Automation Student Developers Session 3: Introduction to UI Automation
 
CNSCon 2024 Lightning Talk: Don’t Make Me Impersonate My Identity
CNSCon 2024 Lightning Talk: Don’t Make Me Impersonate My IdentityCNSCon 2024 Lightning Talk: Don’t Make Me Impersonate My Identity
CNSCon 2024 Lightning Talk: Don’t Make Me Impersonate My Identity
 
So You've Lost Quorum: Lessons From Accidental Downtime
So You've Lost Quorum: Lessons From Accidental DowntimeSo You've Lost Quorum: Lessons From Accidental Downtime
So You've Lost Quorum: Lessons From Accidental Downtime
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
 
Containers & AI - Beauty and the Beast!?!
Containers & AI - Beauty and the Beast!?!Containers & AI - Beauty and the Beast!?!
Containers & AI - Beauty and the Beast!?!
 

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
  翻译: