SlideShare ist ein Scribd-Unternehmen logo
1 von 17
POLYMORPHISM
          Concept & Application




         Prepared By:-
         Rakhi Kumari
         Kumar Gaurav
Polymorphism: Literal meaning
• polymorphism in Latin word which made up of
  'poly' means many and 'morphs' means forms.

• From the Greek:
  – Polus + Morphe = Polumorphos
    (many ) (shape/form)


• This is something similar to a word having several
  different meanings depending on the context
A simple word ‘Cut’ can have different meaning
depending where it is used
Polymorphism, In Context Of OOP
• Polymorphism is about an objects ability to
  provide context when methods or operators
  are called on the object.
• In OOP, Polymorphism is the characteristic of
  being able to assign a different meaning to a
  particular symbol or "operator" in different
  contexts - specifically, to allow an entity such
  as a variable, a function, or an object to have
  more than one form.
Polymorphism
• When a program invokes a method through a
  superclass variable,
  – the correct subclass version of the method is
    called,
  – based on the type of the reference stored in the
    superclass variable
• The same method name and signature can
  cause different actions to occur,
  – depending on the type of object on which the
    method is invoked
                                                       5
Polymorphism
• Polymorphism enables programmers to deal
  in generalities and
  – let the execution-time environment handle the
    specifics.
• Programmers can command objects to behave
  in manners appropriate to those objects,
  – without knowing the types of the objects
  – (as long as the objects belong to the same
    inheritance hierarchy).

                                                    6
The Meaning of the word.
• Example: The operator + has a different
  meaning in the expression 2 + 3 (add two
  integers) than in 1.7 + 3.3 (add two floating
  point numbers)




                                                  7
Types of polymorphism
• 1. compile time polymorphism
        ( function and operator overloading)



• 2.run time polymorphism
                  (virtual functions)
Method & Function Overloading

• Overloading a function simply means, that a
  function is not only defined its name but by its
  name and parameter types.
                                          These three
• The following functions are different in C++: are
                                         methods
  – Int area(int i, int k);                different.
  – void area( float i, float k);
  – Float area();


                                                        9
Method Overloading
using System;
                                              class maindemo
using System.Collections.Generic;               {
using System.Linq;                              static void Main(string[] args)
using System.Text;                                 {
                                                   Area a1= new Area();
                                                   a1.length=10;
                                                   a1.breadth=20;
  class Area{                                      int area1 =a1.calc(10,20);
     public double length;                         double area2= a1.calc(10.5, 20.2);
     public double breadth;                        a1.calc();
                                                   Console.WriteLine();
                                                   Console.Write("Area =" + area1);
      public int calc(int l, int b)
                                                   Console.WriteLine();
      { return (l * b); }                          Console.Write("Area =" + area2);
      public double calc(double l,double b)        Console.WriteLine();
      { return (l * b); }                          }
      public void calc()                        }
      { Console.Write("Area =" + 40 ); }
  }
output
Area=40;
Area=200;
Area=212.1;
Method overriding
                                             class car:vechile
using System;
                                                {
Using System.Collections.Generic;                   public override void display()
using System.Linq;                                     {
using System.Text;                                         Console.WriteLine(" It is from
                                                                          child Car");
                                                         }
                                                  }
  class vechile                                   class maindemo
  {                                         {
     public virtual void display()                static void Main(string[] args)
      {                                             {
                                                          vechile v1= new car();
         Console.WriteLine(“It is from
                                                           v1.display();
                        parent Vechile");            }
       }                                       }
  }
output
It is from child Car
Run-time polymorphism
• Run-time polymorphism, also called dynamic
  binding, or late binding is often considered as
  the object oriented feature of C#.
• Dynamic means objects are created at run
  time
• Dynamic binding offers greater flexibility and a
  higher level of abstraction than static binding
  because it is done "on the fly" when a
  program executes
Static typing & Dynamic binding

• Static typing means that the   • Dynamic binding means that
  legality of a member             the address of the code in a
  function invocation is           member function invocation
  checked at the earliest          is determined at the last
  possible moment: by the          possible moment: based on
                                   the dynamic type of the
  compiler at compile time.
                                   object at run time. It is called
  The compiler uses the static     "dynamic binding" because
  type of the pointer to           the binding to the code that
  determine whether the            actually gets called is
  member function                  accomplished dynamically
  invocation is legal.             (at run time).

                                                                 15
Static typing & Dynamic binding
• With static binding, you • Dynamic binding offers
  get better run time        greater flexibility and a
  efficiency because the     higher level of
  compiler can actually      abstraction than static
  optimize the code          binding because it is
  before running it.         done "on the fly" when
                             a program executes.
• The CLR knows how        • The CLR doesn't know
  much memory to take        how much memory to
  up for the static method   take up for the dynamic
  object                     method object
Polymorphism

Weitere ähnliche Inhalte

Was ist angesagt?

Pointers, virtual function and polymorphism
Pointers, virtual function and polymorphismPointers, virtual function and polymorphism
Pointers, virtual function and polymorphismlalithambiga kamaraj
 
Characteristics of OOPS
Characteristics of OOPS Characteristics of OOPS
Characteristics of OOPS abhishek kumar
 
OOP Introduction with java programming language
OOP Introduction with java programming languageOOP Introduction with java programming language
OOP Introduction with java programming languageMd.Al-imran Roton
 
C++ concept of Polymorphism
C++ concept of  PolymorphismC++ concept of  Polymorphism
C++ concept of Polymorphismkiran Patel
 
Inheritance
InheritanceInheritance
InheritanceTech_MX
 
Polymorphism Using C++
Polymorphism Using C++Polymorphism Using C++
Polymorphism Using C++PRINCE KUMAR
 
Comparison between runtime polymorphism and compile time polymorphism
Comparison between runtime polymorphism and compile time polymorphismComparison between runtime polymorphism and compile time polymorphism
Comparison between runtime polymorphism and compile time polymorphismCHAITALIUKE1
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++Vishal Patil
 
C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...
C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...
C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...Simplilearn
 
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 hdmHarshal Misalkar
 
Call by value or call by reference in C++
Call by value or call by reference in C++Call by value or call by reference in C++
Call by value or call by reference in C++Sachin Yadav
 
Polymorphism in java, method overloading and method overriding
Polymorphism in java,  method overloading and method overridingPolymorphism in java,  method overloading and method overriding
Polymorphism in java, method overloading and method overridingJavaTportal
 
Polymorphism presentation in java
Polymorphism presentation in javaPolymorphism presentation in java
Polymorphism presentation in javaAhsan Raja
 

Was ist angesagt? (20)

Pointers, virtual function and polymorphism
Pointers, virtual function and polymorphismPointers, virtual function and polymorphism
Pointers, virtual function and polymorphism
 
Characteristics of OOPS
Characteristics of OOPS Characteristics of OOPS
Characteristics of OOPS
 
Java inheritance
Java inheritanceJava inheritance
Java inheritance
 
OOP Introduction with java programming language
OOP Introduction with java programming languageOOP Introduction with java programming language
OOP Introduction with java programming language
 
C++ concept of Polymorphism
C++ concept of  PolymorphismC++ concept of  Polymorphism
C++ concept of Polymorphism
 
OOPS Basics With Example
OOPS Basics With ExampleOOPS Basics With Example
OOPS Basics With Example
 
Inheritance
InheritanceInheritance
Inheritance
 
Method overloading
Method overloadingMethod overloading
Method overloading
 
Polymorphism Using C++
Polymorphism Using C++Polymorphism Using C++
Polymorphism Using C++
 
Comparison between runtime polymorphism and compile time polymorphism
Comparison between runtime polymorphism and compile time polymorphismComparison between runtime polymorphism and compile time polymorphism
Comparison between runtime polymorphism and compile time polymorphism
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
Encapsulation
EncapsulationEncapsulation
Encapsulation
 
C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...
C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...
C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...
 
Encapsulation C++
Encapsulation C++Encapsulation C++
Encapsulation C++
 
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
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
functions of C++
functions of C++functions of C++
functions of C++
 
Call by value or call by reference in C++
Call by value or call by reference in C++Call by value or call by reference in C++
Call by value or call by reference in C++
 
Polymorphism in java, method overloading and method overriding
Polymorphism in java,  method overloading and method overridingPolymorphism in java,  method overloading and method overriding
Polymorphism in java, method overloading and method overriding
 
Polymorphism presentation in java
Polymorphism presentation in javaPolymorphism presentation in java
Polymorphism presentation in java
 

Andere mochten auch

Co crystalization
Co crystalizationCo crystalization
Co crystalizationSujit Kale
 
Cocrystal review 2011
Cocrystal review 2011Cocrystal review 2011
Cocrystal review 2011Simon Curtis
 
Rancidity - oxidation of oils and fats.
Rancidity - oxidation of oils and fats.Rancidity - oxidation of oils and fats.
Rancidity - oxidation of oils and fats.Mansvini Misra
 
Polymorphism and crystallisation : The mysterious phenomenon
Polymorphism and crystallisation : The mysterious phenomenonPolymorphism and crystallisation : The mysterious phenomenon
Polymorphism and crystallisation : The mysterious phenomenonMadhulika Harde
 
Fatty acids
Fatty acidsFatty acids
Fatty acidssjobli74
 
How to Manufacture Oils, Fats and Its Derivatives
 How to Manufacture Oils, Fats and Its Derivatives How to Manufacture Oils, Fats and Its Derivatives
How to Manufacture Oils, Fats and Its DerivativesAjjay Kumar Gupta
 
Seminar on polymorphism
Seminar on polymorphismSeminar on polymorphism
Seminar on polymorphism023henil
 

Andere mochten auch (11)

Co crystalization
Co crystalizationCo crystalization
Co crystalization
 
Cocrystal review 2011
Cocrystal review 2011Cocrystal review 2011
Cocrystal review 2011
 
Rancidity - oxidation of oils and fats.
Rancidity - oxidation of oils and fats.Rancidity - oxidation of oils and fats.
Rancidity - oxidation of oils and fats.
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Rancidity
RancidityRancidity
Rancidity
 
Polymorphism and crystallisation : The mysterious phenomenon
Polymorphism and crystallisation : The mysterious phenomenonPolymorphism and crystallisation : The mysterious phenomenon
Polymorphism and crystallisation : The mysterious phenomenon
 
Fatty acids
Fatty acidsFatty acids
Fatty acids
 
How to Manufacture Oils, Fats and Its Derivatives
 How to Manufacture Oils, Fats and Its Derivatives How to Manufacture Oils, Fats and Its Derivatives
How to Manufacture Oils, Fats and Its Derivatives
 
M.PHARM_ Rupsa Ghosh
M.PHARM_ Rupsa GhoshM.PHARM_ Rupsa Ghosh
M.PHARM_ Rupsa Ghosh
 
Seminar on polymorphism
Seminar on polymorphismSeminar on polymorphism
Seminar on polymorphism
 
Fatty acid synthesis
Fatty acid synthesisFatty acid synthesis
Fatty acid synthesis
 

Ähnlich wie Polymorphism

Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17LogeekNightUkraine
 
21CSC101T best ppt ever OODP UNIT-2.pptx
21CSC101T best ppt ever OODP UNIT-2.pptx21CSC101T best ppt ever OODP UNIT-2.pptx
21CSC101T best ppt ever OODP UNIT-2.pptxAnantjain234527
 
cbybalaguruswami-e-180803051831.pptx
cbybalaguruswami-e-180803051831.pptxcbybalaguruswami-e-180803051831.pptx
cbybalaguruswami-e-180803051831.pptxSRamadossbiher
 
cbybalaguruswami-e-180803051831.pptx
cbybalaguruswami-e-180803051831.pptxcbybalaguruswami-e-180803051831.pptx
cbybalaguruswami-e-180803051831.pptxSRamadossbiher
 
Java script Techniques Part I
Java script Techniques Part IJava script Techniques Part I
Java script Techniques Part ILuis Atencio
 
Contract First Development with Microsoft Code Contracts and Microsoft Pex at...
Contract First Development with Microsoft Code Contracts and Microsoft Pex at...Contract First Development with Microsoft Code Contracts and Microsoft Pex at...
Contract First Development with Microsoft Code Contracts and Microsoft Pex at...Theo Jungeblut
 
C, C++ Interview Questions Part - 1
C, C++ Interview Questions Part - 1C, C++ Interview Questions Part - 1
C, C++ Interview Questions Part - 1ReKruiTIn.com
 
Clean Code at Silicon Valley Code Camp 2011 (02/17/2012)
Clean Code at Silicon Valley Code Camp 2011 (02/17/2012)Clean Code at Silicon Valley Code Camp 2011 (02/17/2012)
Clean Code at Silicon Valley Code Camp 2011 (02/17/2012)Theo Jungeblut
 
P/Invoke - Interoperability of C++ and C#
P/Invoke - Interoperability of C++ and C#P/Invoke - Interoperability of C++ and C#
P/Invoke - Interoperability of C++ and C#Rainer Stropek
 
Polymorphism & Templates
Polymorphism & TemplatesPolymorphism & Templates
Polymorphism & TemplatesMeghaj Mallick
 
Cross Platform App Development with C++
Cross Platform App Development with C++Cross Platform App Development with C++
Cross Platform App Development with C++Joan Puig Sanz
 
CAP444-Unit-3-Polymorphism.pptx
CAP444-Unit-3-Polymorphism.pptxCAP444-Unit-3-Polymorphism.pptx
CAP444-Unit-3-Polymorphism.pptxSurajgroupsvideo
 
Clean Code for East Bay .NET User Group
Clean Code for East Bay .NET User GroupClean Code for East Bay .NET User Group
Clean Code for East Bay .NET User GroupTheo Jungeblut
 

Ähnlich wie Polymorphism (20)

C# Unit 2 notes
C# Unit 2 notesC# Unit 2 notes
C# Unit 2 notes
 
Presentation.pptx
Presentation.pptxPresentation.pptx
Presentation.pptx
 
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
 
21CSC101T best ppt ever OODP UNIT-2.pptx
21CSC101T best ppt ever OODP UNIT-2.pptx21CSC101T best ppt ever OODP UNIT-2.pptx
21CSC101T best ppt ever OODP UNIT-2.pptx
 
C by balaguruswami - e.balagurusamy
C   by balaguruswami - e.balagurusamyC   by balaguruswami - e.balagurusamy
C by balaguruswami - e.balagurusamy
 
cbybalaguruswami-e-180803051831.pptx
cbybalaguruswami-e-180803051831.pptxcbybalaguruswami-e-180803051831.pptx
cbybalaguruswami-e-180803051831.pptx
 
cbybalaguruswami-e-180803051831.pptx
cbybalaguruswami-e-180803051831.pptxcbybalaguruswami-e-180803051831.pptx
cbybalaguruswami-e-180803051831.pptx
 
Java script Techniques Part I
Java script Techniques Part IJava script Techniques Part I
Java script Techniques Part I
 
Contract First Development with Microsoft Code Contracts and Microsoft Pex at...
Contract First Development with Microsoft Code Contracts and Microsoft Pex at...Contract First Development with Microsoft Code Contracts and Microsoft Pex at...
Contract First Development with Microsoft Code Contracts and Microsoft Pex at...
 
Polymorphismupload
PolymorphismuploadPolymorphismupload
Polymorphismupload
 
C, C++ Interview Questions Part - 1
C, C++ Interview Questions Part - 1C, C++ Interview Questions Part - 1
C, C++ Interview Questions Part - 1
 
Dr archana dhawan bajaj - c# dot net
Dr archana dhawan bajaj - c# dot netDr archana dhawan bajaj - c# dot net
Dr archana dhawan bajaj - c# dot net
 
Clean Code at Silicon Valley Code Camp 2011 (02/17/2012)
Clean Code at Silicon Valley Code Camp 2011 (02/17/2012)Clean Code at Silicon Valley Code Camp 2011 (02/17/2012)
Clean Code at Silicon Valley Code Camp 2011 (02/17/2012)
 
C# for Java Developers
C# for Java DevelopersC# for Java Developers
C# for Java Developers
 
P/Invoke - Interoperability of C++ and C#
P/Invoke - Interoperability of C++ and C#P/Invoke - Interoperability of C++ and C#
P/Invoke - Interoperability of C++ and C#
 
Polymorphism & Templates
Polymorphism & TemplatesPolymorphism & Templates
Polymorphism & Templates
 
Cross Platform App Development with C++
Cross Platform App Development with C++Cross Platform App Development with C++
Cross Platform App Development with C++
 
EEE 3rd year oops cat 3 ans
EEE 3rd year  oops cat 3  ansEEE 3rd year  oops cat 3  ans
EEE 3rd year oops cat 3 ans
 
CAP444-Unit-3-Polymorphism.pptx
CAP444-Unit-3-Polymorphism.pptxCAP444-Unit-3-Polymorphism.pptx
CAP444-Unit-3-Polymorphism.pptx
 
Clean Code for East Bay .NET User Group
Clean Code for East Bay .NET User GroupClean Code for East Bay .NET User Group
Clean Code for East Bay .NET User Group
 

Mehr von Kumar Gaurav

Mehr von Kumar Gaurav (6)

Numerical method
Numerical methodNumerical method
Numerical method
 
Cellular network History
Cellular network HistoryCellular network History
Cellular network History
 
Cellular networks
Cellular networksCellular networks
Cellular networks
 
Standard Template Library
Standard Template LibraryStandard Template Library
Standard Template Library
 
J2ME
J2MEJ2ME
J2ME
 
Python
PythonPython
Python
 

Kürzlich hochgeladen

Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxdhanalakshmis0310
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 

Kürzlich hochgeladen (20)

Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 

Polymorphism

  • 1. POLYMORPHISM Concept & Application Prepared By:- Rakhi Kumari Kumar Gaurav
  • 2. Polymorphism: Literal meaning • polymorphism in Latin word which made up of 'poly' means many and 'morphs' means forms. • From the Greek: – Polus + Morphe = Polumorphos (many ) (shape/form) • This is something similar to a word having several different meanings depending on the context
  • 3. A simple word ‘Cut’ can have different meaning depending where it is used
  • 4. Polymorphism, In Context Of OOP • Polymorphism is about an objects ability to provide context when methods or operators are called on the object. • In OOP, Polymorphism is the characteristic of being able to assign a different meaning to a particular symbol or "operator" in different contexts - specifically, to allow an entity such as a variable, a function, or an object to have more than one form.
  • 5. Polymorphism • When a program invokes a method through a superclass variable, – the correct subclass version of the method is called, – based on the type of the reference stored in the superclass variable • The same method name and signature can cause different actions to occur, – depending on the type of object on which the method is invoked 5
  • 6. Polymorphism • Polymorphism enables programmers to deal in generalities and – let the execution-time environment handle the specifics. • Programmers can command objects to behave in manners appropriate to those objects, – without knowing the types of the objects – (as long as the objects belong to the same inheritance hierarchy). 6
  • 7. The Meaning of the word. • Example: The operator + has a different meaning in the expression 2 + 3 (add two integers) than in 1.7 + 3.3 (add two floating point numbers) 7
  • 8. Types of polymorphism • 1. compile time polymorphism ( function and operator overloading) • 2.run time polymorphism (virtual functions)
  • 9. Method & Function Overloading • Overloading a function simply means, that a function is not only defined its name but by its name and parameter types. These three • The following functions are different in C++: are methods – Int area(int i, int k); different. – void area( float i, float k); – Float area(); 9
  • 10. Method Overloading using System; class maindemo using System.Collections.Generic; { using System.Linq; static void Main(string[] args) using System.Text; { Area a1= new Area(); a1.length=10; a1.breadth=20; class Area{ int area1 =a1.calc(10,20); public double length; double area2= a1.calc(10.5, 20.2); public double breadth; a1.calc(); Console.WriteLine(); Console.Write("Area =" + area1); public int calc(int l, int b) Console.WriteLine(); { return (l * b); } Console.Write("Area =" + area2); public double calc(double l,double b) Console.WriteLine(); { return (l * b); } } public void calc() } { Console.Write("Area =" + 40 ); } }
  • 12. Method overriding class car:vechile using System; { Using System.Collections.Generic; public override void display() using System.Linq; { using System.Text; Console.WriteLine(" It is from child Car"); } } class vechile class maindemo { { public virtual void display() static void Main(string[] args) { { vechile v1= new car(); Console.WriteLine(“It is from v1.display(); parent Vechile"); } } } }
  • 13. output It is from child Car
  • 14. Run-time polymorphism • Run-time polymorphism, also called dynamic binding, or late binding is often considered as the object oriented feature of C#. • Dynamic means objects are created at run time • Dynamic binding offers greater flexibility and a higher level of abstraction than static binding because it is done "on the fly" when a program executes
  • 15. Static typing & Dynamic binding • Static typing means that the • Dynamic binding means that legality of a member the address of the code in a function invocation is member function invocation checked at the earliest is determined at the last possible moment: by the possible moment: based on the dynamic type of the compiler at compile time. object at run time. It is called The compiler uses the static "dynamic binding" because type of the pointer to the binding to the code that determine whether the actually gets called is member function accomplished dynamically invocation is legal. (at run time). 15
  • 16. Static typing & Dynamic binding • With static binding, you • Dynamic binding offers get better run time greater flexibility and a efficiency because the higher level of compiler can actually abstraction than static optimize the code binding because it is before running it. done "on the fly" when a program executes. • The CLR knows how • The CLR doesn't know much memory to take how much memory to up for the static method take up for the dynamic object method object