首页 试题详情
单选题

在C#中,下列代码报错的原因是( ) public interface IAnimal { //Eat()方法报错 public void Eat(); }

AEat()方法没有添加方法体,导致报错。

BEat()方法作为IAnimal接口的成员方法,不允许添加任何访问修饰符,加了Public修饰,导致报错。

CIAnimal作为接口,前面加了Public访问修饰符修饰,导致报错。

DEat()方法命名不规范,导致报错。

正确答案:A (备注:此答案有误)

相似试题

  • 单选题

    C#下列代码原因( ) public interface IAnimal { //Eat()方法 public void Eat(); }

    答案解析

  • 单选题

    C#下列代码原因()? interface IAnimal {//Eat方法 void Eat() { Console.WriteLine("动物需要吃饭。"); } }

    答案解析

  • 单选题

    C#下列代码原因()? _x000D_interface IAnimal {_x000D_//Eat方法_x000D_ void Eat() {_x000D_ Console.WriteLine("动物需要吃饭。");_x000D_ } }

    答案解析

  • 单选题

    C#,对于下列代码出错原因,描述正确( )class Program { static void Main(string[] args) { //创建Appliance对象时报 Appliance apl = new Appliance(); Appliance mlp = new MobilePhone(); } } abstract class Appliance { public abstract void Charge(); } class MobilePhone : Appliance { public void Call() { Console.WriteLine("手机可以打电话。"); } public override void Charge() { Consol

    答案解析

  • 单选题

    C#,通过类()特性,可以重复使用已有代码和数据。

    答案解析

热门题库