.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Interview Question >> C# >> Post New Question Subscribe to Interview Questions

How does VB.NET/C# achieve polymorphism?

Posted By :Shashi Ray     Posted Date :July 15, 2009    Points :10   Category :C# 
VB.Net / C# provide polymorphism through the following mechanisms:
1. Inheritance - base class provides overridable methods which are re-implemented in derived classes.
2. Interface - different class can implement same interface, resulting in different implementations of interface methods.
3. Virtual methods - achieve runtime polymorphism.

You can also find related Interview Question to How does VB.NET/C# achieve polymorphism?  below: 

2. How does VB.NET/C# achieve polymorphism?

  
Function overloading.
Operator overloading. (More...)

What is Polymorphism?

  
In OPP'S, polymorphism(Greek meaning "having multiple forms") is the ablity of being able to assign a different meaning or usage to something in different contexts - specifically, to allow an entity such as a a function, or an object to have more than one forms.

In C# :
Parent classes may define and implement "virtual" methods(Which is done using the "virtual" keyword), and derived classes can override them(using the "override" keyword), which means they provide their own definition and implementation.At run-time, when user's code calls the method, the CLR looks up the run-time type of the object, and invokes that override of the virtual method. Thus in your source code when a method of the base class is called it executes the overriden method.

====================================================================
Regards Hefin Dsouza. (More...)

How can achieve data abstraction?

  
By Modifiers We can achieve data abstraction (More...)

How Polymorphism is achieved in C#.Net?

  
Using virtual/abstract and override keywords.

Explanation:
Polymorphism means different behavior.

Eg: Shape having method Draw()
Square derived from Shape overrides the Draw() method
Circle derived from Shape overrides the Draw() method

We can use the virtual/abstract keyword to declare the Draw()
method in the base Shape class.

Then we can use the override keyword in Square/Circle class to
implement the Draw() method. (More...)

You are having project1.exe referring util.dll.
Now you wanted util.dll to call a method in project1.exe.

How you will achieve this?

  
Use callback interface

or

Use callback delegates

(similar to button on msft dll calling event on our app) (More...)

Types of Polymorphism in OOP

  
This blog shows the types of polymorphism in OOP concept

Types of Polymorphism

· Compile time Polymorphism (method overloading)

· Run time Polymorphism (method overriding) (More...)

All about Polymorphism

  
· Polymorphism is one of the primary characteristics (concept) of object-oriented programming.

· Poly means many and morph means form. Thus, polymorphism refers to being able to use many forms of a type without regard to the details.

· Polymorphism is the characteristic of being able to assign a different meaning specifically, to allow an entity such as a variable, a function, or an object to have more than one form.

· Polymorphism is the ability to process objects differently depending on their data types.

· Polymorphism is the ability to redefine methods for derived classes. (More...)

What is Polymorphism?

  
more than one form. Ability to provide different implementation based on different number or type of parameters. (More...)

What is the difference between compile time polymorphism and run time polymorphism

  
Compile time Polymorphism

Compile time Polymorphism also known as method overloading.

Method overloading means having two or more methods with the same name but with different signatures.

Run time Polymorphism

Run time Polymorphism also known as method overriding.

Method overriding means having two or more methods with the same name , same signature but with different implementation. (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

 
Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.


Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend