Polymorphism in ASP.Net

  • Thread starter Thread starter Danny Ni
  • Start date Start date
D

Danny Ni

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
 
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
 
Buddy Ackerman said:
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.
 
Thank you all very much for making me more confused.
Does that mean OnInit() method exhibit polymorphism?

Thanks Again
 
Jay B. Harlow said:
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 :)
 
Back
Top