C Sharp (C#) - Inheritance
Given this code, what will be the output?
class Animal {
public virtual string Sound() => "Some sound";
}
class Dog : Animal {
public override string Sound() => "Bark";
}
class Cat : Animal {
public override string Sound() => "Meow";
}
class Program {
static void Main() {
Animal[] pets = { new Dog(), new Cat(), new Animal() };
foreach (var pet in pets) {
System.Console.WriteLine(pet.Sound());
}
}
}