试题详情

在C#中,下列代码需要输出”小狗喜欢吃骨头”,“小猫蹲着睡”,则需要在Main()方法中添加的代码是() class Program { static void Main(string[] args) { //在这一个位置写入代码 } } abstract class Animal { public abstract void Eat(); } class Dog : Animal { public override void Eat() { Console.WriteLine("小狗喜欢吃骨头。"); } public void Sleep() { Console.WriteLine("小狗趴着睡。"); } } class Cat : Animal { public override void Eat() { Console.WriteLine("小猫喜欢吃鱼。"); } public void Sleep() { Console.WriteLine("小猫蹲着睡。"); } }

AAnimal dog = new Dog(); dog.Eat(); Animal cat = new Cat(); cat.Eat();

BAnimal dog = new Dog(); dog.Eat(); Animal cat = new Cat(); cat.Sleep();

CAnimal dog = new Dog(); dog.Eat(); Cat cat = new Cat(); cat.Sleep();

DDog dog = new Dog(); dog.Sleep(); Cat cat = new Cat(); cat.Eat();