Different between method overriding and method overloading?



Different between method overriding and method overloading?..

Answer / Yogesh Kumar Sagar

Method Overriding is a situation where a subclass provides its own implementation of a method that is already provided by its superclass. Method Overloading, on the other hand, refers to having multiple methods with the same name but different parameters in the same class.n```csharpnpublic class Animal {n public virtual void Eat() {n Console.WriteLine("The animal is eating.");n }n}npublic class Dog : Animal {n public override void Eat() {n Console.WriteLine("The dog is eating bones.");n }npublic class Cat : Animal {n public void Eat(string food) {n Console.WriteLine("The cat is eating " + food + ".");n }n}n```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Sharp Interview Questions

What is a collection class in c#?

1 Answers  


Explain the difference between // comments, /* */ comments and /// comments?

1 Answers  


What is instantiating a class in c#?

1 Answers  


What is the default modifier for class in c#?

1 Answers  


What do you mean by expression tree?

1 Answers  


Can we inherit static class in c#?

1 Answers  


What is this keyword in C#?

1 Answers  


Is datetime value type c#?

1 Answers  


Explain the Different types of configuration files in .net?

1 Answers  


What is the base class for array types?

1 Answers  


How does the lifecycle of Windows services differ from Standard EXE?

1 Answers   Siebel Systems,


How do I format in c#?

1 Answers  


Categories