473,320 Members | 1,957 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Polymorphism in ASP.Net

Hi,

I was asked a question in a recent interview, where in ASP.Net is
polymorphism used?

I got differrent answers from different people,
One said ToString() method because it is working for different classes.
One said OnInit() method of System.Web.UI.Page class because it's defined
virtual and that's the key to polymorphism.

The most concise definition I can find for polymorphism:
Same method reacts differently for different class.

Any comments?

Thanks in Advance

Jul 21 '05 #1
10 5182
I'm not THE expert on this but I think it's when the same method is used
multiple times within the same class and has a different interface. The
most obvious example is the overloaded constructors in the classes and in
general any method that is overloaded.
--Buddy

"Danny Ni" <dn**@yahoo.com> wrote in message
news:uY**************@TK2MSFTNGP12.phx.gbl...
Hi,

I was asked a question in a recent interview, where in ASP.Net is
polymorphism used?

I got differrent answers from different people,
One said ToString() method because it is working for different classes.
One said OnInit() method of System.Web.UI.Page class because it's defined
virtual and that's the key to polymorphism.

The most concise definition I can find for polymorphism:
Same method reacts differently for different class.

Any comments?

Thanks in Advance

Jul 21 '05 #2
Buddy Ackerman <bu**************@buddyackerman.com> wrote:
I'm not THE expert on this but I think it's when the same method is used
multiple times within the same class and has a different interface. The
most obvious example is the overloaded constructors in the classes and in
general any method that is overloaded.


No, overloading isn't polymorphism - overriding is polymorphism.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #3
Cor
Hi Jon,

Just an addition for the OP.

And can be used in ASP.NET.

Cor

No, overloading isn't polymorphism - overriding is polymorphism.

Jul 21 '05 #4
Jon,
I understand that Overloading IS "ad hoc" polymorphism!

While Overriding is "universal - parametric" polymorphism.

http://www.javaworld.com/javaworld/j...polymorph.html

Hope this helps
Jay

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Buddy Ackerman <bu**************@buddyackerman.com> wrote:
I'm not THE expert on this but I think it's when the same method is used
multiple times within the same class and has a different interface. The
most obvious example is the overloaded constructors in the classes and in general any method that is overloaded.


No, overloading isn't polymorphism - overriding is polymorphism.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Jul 21 '05 #5
Doh!
While Overriding is "universal - parametric" polymorphism. Overriding is "universal - inclusion" (or subtype) polymorphism.

We need to wait for Generics before we will have parametric polymorphism.

Jay

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:O9*************@tk2msftngp13.phx.gbl... Jon,
I understand that Overloading IS "ad hoc" polymorphism!

While Overriding is "universal - parametric" polymorphism.

http://www.javaworld.com/javaworld/j...polymorph.html

Hope this helps
Jay

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Buddy Ackerman <bu**************@buddyackerman.com> wrote:
I'm not THE expert on this but I think it's when the same method is used multiple times within the same class and has a different interface. The most obvious example is the overloaded constructors in the classes and in general any method that is overloaded.


No, overloading isn't polymorphism - overriding is polymorphism.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Jul 21 '05 #6
Thank you all very much for making me more confused.
Does that mean OnInit() method exhibit polymorphism?

Thanks Again

"Danny Ni" <dn**@yahoo.com> wrote in message
news:uY**************@TK2MSFTNGP12.phx.gbl...
Hi,

I was asked a question in a recent interview, where in ASP.Net is
polymorphism used?

I got differrent answers from different people,
One said ToString() method because it is working for different classes.
One said OnInit() method of System.Web.UI.Page class because it's defined
virtual and that's the key to polymorphism.

The most concise definition I can find for polymorphism:
Same method reacts differently for different class.

Any comments?

Thanks in Advance

Jul 21 '05 #7
Danny,
Yes, as it virtual, virtual means you can overload.

Jay

"Danny Ni" <dn**@yahoo.com> wrote in message
news:uU**************@TK2MSFTNGP10.phx.gbl...
Thank you all very much for making me more confused.
Does that mean OnInit() method exhibit polymorphism?

Thanks Again

"Danny Ni" <dn**@yahoo.com> wrote in message
news:uY**************@TK2MSFTNGP12.phx.gbl...
Hi,

I was asked a question in a recent interview, where in ASP.Net is
polymorphism used?

I got differrent answers from different people,
One said ToString() method because it is working for different classes.
One said OnInit() method of System.Web.UI.Page class because it's defined virtual and that's the key to polymorphism.

The most concise definition I can find for polymorphism:
Same method reacts differently for different class.

Any comments?

Thanks in Advance


Jul 21 '05 #8
Jay B. Harlow [MVP - Outlook] <Ja************@msn.com> wrote:
Yes, as it virtual, virtual means you can overload.


No, virtual means you can *override*.

(I know this was just a slip of the fingers - I'm only correcting it
for the OP's benefit :)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #9
Jay B. Harlow [MVP - Outlook] <Ja************@msn.com> wrote:
I understand that Overloading IS "ad hoc" polymorphism!

While Overriding is "universal - parametric" polymorphism.

http://www.javaworld.com/javaworld/j...polymorph.html


Interesting - I haven't seen that definition before. (Foldoc gives a
shorter but similar definition though.)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #10
Jon,
Doh! yep I meant override...

Thanks for catching it...

Jay

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Jay B. Harlow [MVP - Outlook] <Ja************@msn.com> wrote:
Yes, as it virtual, virtual means you can overload.


No, virtual means you can *override*.

(I know this was just a slip of the fingers - I'm only correcting it
for the OP's benefit :)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Jul 21 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

37
by: Mike Meng | last post by:
hi all, I'm a newbie Python programmer with a C++ brain inside. I have a lightweight framework in which I design a base class and expect user to extend. In other part of the framework, I heavily...
18
by: Ken | last post by:
Hi. Can anyone refer me to any articles about the compatibility between c++ polymorphism and real-time programming? I'm currently on a real-time c++ project, and we're having a discussion...
3
by: E. Robert Tisdale | last post by:
polymorph just means "many form(s)". The definition in plain English http://www.bartleby.com/61/66/P0426600.html and narrower definitions in the context of computer programming ...
11
by: richard pickworth | last post by:
Can anyone explain polymorphism?(very simply). thanks richard
4
by: LP | last post by:
Hi, I understand the concept/definition of polymorphism. But what does the term "runtime polymorphism" mean? I was asked to define it during a technical interview. I gave a guy vanilla definition...
13
by: Krivenok Dmitry | last post by:
Hello all! Perhaps the most important feature of dynamic polymorphism is ability to handle heterogeneous collections of objects. ("C++ Templates: The Complete Guide" by David Vandevoorde and...
18
by: Seigfried | last post by:
I have to write a paper about object oriented programming and I'm doing some reading to make sure I understand it. In a book I'm reading, however, polymorphism is defined as: "the ability of two...
2
by: sarathy | last post by:
Hi all, I need a small clarification reg. Templates and Polymorphism. I believe templates is really a good feature, which can be used to implement generic functions and classes. But i doubt...
11
by: chsalvia | last post by:
I've been programming in C++ for a little over 2 years, and I still find myself wondering when I should use polymorphism. Some people claim that polymorphism is such an integral part of C++,...
17
by: Bart Friederichs | last post by:
Hello, I created the following inheritance: class Parent { public: void foo(int i); }; class Child : public Parent {
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.