December Code

December Code / Try C#

Try C#

No account needed. Answer, see why, move on.

1 of 3 today

Inheritance & Polymorphismeasy

What does this C# code print?

Animal[] zoo = { new Animal(), new Dog(), new Puppy() };
foreach (var a in zoo)
    Console.Write(a.Sound() + " ");

class Animal {
    public virtual string Sound() => "...";
}
class Dog : Animal {
    public override string Sound() => "Woof";
}
class Puppy : Dog { }
Choose one option
choose an option

Nothing here is saved. Create a free account to keep your progress, take an assessment and get your readiness score.