Technology Guruu

  • Home
  • Site Info
    • About Us
    • Disclaimer
    • Privacy Polacy
  • Home
  • Digital Marketing
    • SEO
    • SMM
    • SEM
  • Quotes
  • Technical
  • Java
  • .Net
    • C#.Net
    • ASP.Net
  • Keychains

Saturday, 2 April 2016

Polymorphism in OOPs

 Akansha     17:30:00     TechnicalQuestions     No comments   

Every interviwer asking first question is what is polymorphism and how it can be works,what are the uses of plymorphism in programming development.why it so important because this concept is heart of all programming languages. so we are definitely know these topic and also know the how to develop a programme through examples.

Polymorphism in C#.Net

hd wallpapers for polymorphism
Polymorphism

Polymorphism:

Polymorphism means one name in many forms. Implemnting multiple methods with the same name but different signature is called as polymorphism.
It is of 2 types.
1.Static Polymorphism or Compile Time Polymorphism
2.Dynamic Polymorphism or Run Time Polymorphism
1.Static Polymorphism:
  A method which will bind at compile time will execute in runtime is called as static polymorphism or compile time polymorphism.We can achieve this by using function overloading.
What is function overloading?
   Having multiple methods with the same name but different signature i.e., different no.of arguments or  different type of arguments or different order of arguments in a single class or in a combination of base and derived class.
When: Whenever we want to implement same method with the different functionalities then we have to go for function overloading.
Ex: Example to understand function over loading
class MyClass
{
internal void Print(int a)
{
Console.WriteLine("int value is:"+a);
}
internal void Print(string s)
{
Console.WriteLine("string value is:"+s);
}
}
class Program
{
static void Main(string[] args)
{
MyClass obj=new MyClass();
obj.Print(10);
Console.ReadLine();
}
}
       When we compile the above program at compile time it will bind the first method and when we run that program it will execute the first method of MyClass.
Observation:  A method which is binding at compile time is executing in runtime. Due to that reason function overloading is called as static polymorphism.

2.Dynamic Polymorphism:  

A method which will bind at compile time will not execute, Instead of that a method which will bind at run time will execute is called as Dynamic Polymorphism or Run Time Polymorphism. We can achieve this by using function overriding.

Function Overriding:  Having multiple methods wieh the same name and with the same signature in combination of base and derived class.
When:  Whenever we want to implement a method in multiple classes with the different behaviour we can go for function overriding.
Ex: Example to understand function over riding
class bc
{
internal void Print()
{
Console.WriteLine("bc is calling")
}
}
class dc:bc
{
internal void Print()
{
Console.WriteLine("dc is calling")
}
}
class Program
{
static void Main(string[] args)
{
bc obj=new dc();
obj.Print();
Console.ReadLine();
}
}
      When we will compile the above program it will bind yhe super class print method and at run time it will execute the derived class print method so due to that reason function overriding is a dynamic polymorphism.
Share With Your Friends in Social Media (Facebook, Twitter, Google Plus Etc...) if You Like Our Content And Feel Free To Comment.
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Email ThisBlogThis!Share to XShare to Facebook
Newer Post Home

0 comments:

Post a Comment

Popular Posts

  • Missing My Friend Quotes : Friendship Day Quotes 2017
    Friends today my article about missing friends and moments with them. Here you are seen the best friendship quotes and some  feelings when...
  • Love Failure Quotes and Sad valentines day Quotes
    We Love Someone is a easy process sometime takes long time to love someone love others within short period but anyway always love dependin...
  • Brief description about Delegates
    Introduction about delegates and why delegates are came the main purpose of delegates how to useful and what are the advantages and disadv...
  • Na Tanu Samjhawan Ki Song lyrics
    Na Tanu Samjhawan Ki Song Lyrics With English Translation Movie : Humpty Sharma ki Dulhaniya Song : Samjhawan Song Singer : Arijit ...
  • Detail Introduction about C#.Net
    Brief Introduction about C#.Net  Introduction C#.Net is the one of the Programming Language the .Net Framework also contains ano...
  • Wonderful sayings about Life.
    I Believe Follow  Things(Life Quotes) I Believe I believe: ********** Believe in Life ********** That we don't have to chan...
  • Brief Description about Multicast Delegate
    Multicast delegate is an extension of normal delegate. It helps you to point more than one method at a single moment of time. Multicast ...
  • Brief description about properties
    Properties in C#.Net Properties Property is a member of a class which we will use to assign the value to a variable as well as whi...
  • Top 10 valentine's day Quotes and Greetings wishes
    All Lovers have Anxiety in Valentines day because it is a festival to all lovers in these they enjoy a lot and celebrate the Valentine...
  • Valentines day poems and wishes or Quotes
    A friendship that like love is warm; A love like friendship, steady.we are having the most difference between love and Friendship you mus...

Categories

  • Entertainment (67)
  • TechnicalQuestions (58)
  • Quotes (11)
  • C#.Net (8)
  • Java (8)
  • ValentinesDay (4)
  • SEO (3)
  • Home
  • About Us
  • Disclaimer
  • Privacy Policy
  • Sitemap

Copyright © 2015-2017 Good Friends 5.All Rights Reserved• And Our Sitemap • All Logos and Trademark Belongs To Their Respective Owners•