logging in or signing up polymorphism gauravsitu Download Post to : URL : Related Presentations : Share Add to Flag Embed Email Send to Blogs and Networks Add to Channel Uploaded from authorPOINT lite Insert YouTube videos in PowerPont slides with aS Desktop Copy embed code: (To copy code, click on the text box) Embed: URL: Thumbnail: WordPress Embed Customize Embed The presentation is successfully added In Your Favorites. Views: 373 Category: Education License: All Rights Reserved Like it (3) Dislike it (0) Added: August 22, 2010 This Presentation is Public Favorites: 1 Presentation Description OOPs features Comments Posting comment... By: basugupta (8 month(s) ago) please cn u send me dis ppt..... Saving..... Post Reply Close Saving..... Edit Comment Close By: muks289329 (9 month(s) ago) it very well define Saving..... Post Reply Close Saving..... Edit Comment Close By: Nayoncse (13 month(s) ago) Good Saving..... Post Reply Close Saving..... Edit Comment Close Premium member Presentation Transcript POLYMORPHISM Concept & Application : POLYMORPHISM Concept & Application Prepared By:- Rakhi Kumari Kumar Gaurav Polymorphism: Literal meaning : 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 : A simple word ‘Cut’ can have different meaning depending where it is used Polymorphism, In Context Of OOP : 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 : 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 Polymorphism : 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). The Meaning of the word. : 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) Types of polymorphism : Types of polymorphism 1. compile time polymorphism ( function and operator overloading) 2.run time polymorphism (virtual functions) Method & Function Overloading : 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. The following functions are different in C++: Int area(int i, int k); void area( float i, float k); Float area(); These three methods are different. Slide 10: using System; using System.Collections.Generic; using System.Linq; using System.Text; class Area{ public double length; public double breadth; public int calc(int l, int b) { return (l * b); } public double calc(double l,double b) { return (l * b); } public void calc() { Console.Write("Area =" + 40 ); } } class maindemo { static void Main(string[] args) { Area a1= new Area(); a1.length=10; a1.breadth=20; int area1 =a1.calc(10,20); double area2= a1.calc(10.5, 20.2); a1.calc(); Console.WriteLine(); Console.Write("Area =" + area1); Console.WriteLine(); Console.Write("Area =" + area2); Console.WriteLine(); } } Method Overloading output : output Area=40; Area=200; Area=212.1; Method overriding : Method overriding using System; Using System.Collections.Generic; using System.Linq; using System.Text; class vechile { public virtual void display() { Console.WriteLine(“It is from parent Vechile"); } } class car:vechile { public override void display() { Console.WriteLine(" It is from child Car"); } } class maindemo { static void Main(string[] args) { vechile v1= new car(); v1.display(); } } output : output It is from child Car Run-time polymorphism : 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 : 15 Static typing & Dynamic binding Static typing means that the legality of a member function invocation is checked at the earliest possible moment: by the compiler at compile time. The compiler uses the static type of the pointer to determine whether the member function invocation is legal. Dynamic binding means that the address of the code in a member function invocation is determined at the last possible moment: based on the dynamic type of the object at run time. It is called "dynamic binding" because the binding to the code that actually gets called is accomplished dynamically (at run time). Static typing & Dynamic binding : Static typing & Dynamic binding With static binding, you get better run time efficiency because the compiler can actually optimize the code before running it. The CLR knows how much memory to take up for the static method object 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. The CLR doesn't know how much memory to take up for the dynamic method object You do not have the permission to view this presentation. In order to view it, please contact the author of the presentation.
polymorphism gauravsitu Download Post to : URL : Related Presentations : Share Add to Flag Embed Email Send to Blogs and Networks Add to Channel Uploaded from authorPOINT lite Insert YouTube videos in PowerPont slides with aS Desktop Copy embed code: (To copy code, click on the text box) Embed: URL: Thumbnail: WordPress Embed Customize Embed The presentation is successfully added In Your Favorites. Views: 373 Category: Education License: All Rights Reserved Like it (3) Dislike it (0) Added: August 22, 2010 This Presentation is Public Favorites: 1 Presentation Description OOPs features Comments Posting comment... By: basugupta (8 month(s) ago) please cn u send me dis ppt..... Saving..... Post Reply Close Saving..... Edit Comment Close By: muks289329 (9 month(s) ago) it very well define Saving..... Post Reply Close Saving..... Edit Comment Close By: Nayoncse (13 month(s) ago) Good Saving..... Post Reply Close Saving..... Edit Comment Close Premium member Presentation Transcript POLYMORPHISM Concept & Application : POLYMORPHISM Concept & Application Prepared By:- Rakhi Kumari Kumar Gaurav Polymorphism: Literal meaning : 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 : A simple word ‘Cut’ can have different meaning depending where it is used Polymorphism, In Context Of OOP : 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 : 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 Polymorphism : 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). The Meaning of the word. : 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) Types of polymorphism : Types of polymorphism 1. compile time polymorphism ( function and operator overloading) 2.run time polymorphism (virtual functions) Method & Function Overloading : 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. The following functions are different in C++: Int area(int i, int k); void area( float i, float k); Float area(); These three methods are different. Slide 10: using System; using System.Collections.Generic; using System.Linq; using System.Text; class Area{ public double length; public double breadth; public int calc(int l, int b) { return (l * b); } public double calc(double l,double b) { return (l * b); } public void calc() { Console.Write("Area =" + 40 ); } } class maindemo { static void Main(string[] args) { Area a1= new Area(); a1.length=10; a1.breadth=20; int area1 =a1.calc(10,20); double area2= a1.calc(10.5, 20.2); a1.calc(); Console.WriteLine(); Console.Write("Area =" + area1); Console.WriteLine(); Console.Write("Area =" + area2); Console.WriteLine(); } } Method Overloading output : output Area=40; Area=200; Area=212.1; Method overriding : Method overriding using System; Using System.Collections.Generic; using System.Linq; using System.Text; class vechile { public virtual void display() { Console.WriteLine(“It is from parent Vechile"); } } class car:vechile { public override void display() { Console.WriteLine(" It is from child Car"); } } class maindemo { static void Main(string[] args) { vechile v1= new car(); v1.display(); } } output : output It is from child Car Run-time polymorphism : 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 : 15 Static typing & Dynamic binding Static typing means that the legality of a member function invocation is checked at the earliest possible moment: by the compiler at compile time. The compiler uses the static type of the pointer to determine whether the member function invocation is legal. Dynamic binding means that the address of the code in a member function invocation is determined at the last possible moment: based on the dynamic type of the object at run time. It is called "dynamic binding" because the binding to the code that actually gets called is accomplished dynamically (at run time). Static typing & Dynamic binding : Static typing & Dynamic binding With static binding, you get better run time efficiency because the compiler can actually optimize the code before running it. The CLR knows how much memory to take up for the static method object 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. The CLR doesn't know how much memory to take up for the dynamic method object