Create base class Animal with Speak() and override in Dog.
Ready — edit the code above and click Run.
using System;
class Animal { public virtual void Speak() => Console.WriteLine("Some sound"); }
class Dog : Animal { public override void Speak() => Console.WriteLine("Bark"); }
class Program { static void Main() { new Dog().Speak(); } }
Try solving on your own first, then reveal the official answer.
virtual/override enable polymorphism—core OOP interview concept.