接口Animal声明如下:public interface Animal{ void Move();}则下列抽象类的定义中, 是合法的。
A: abstract class Cat: Animal { abstract public void Move(); }
B: abstract class Cat: Animal { virtual public void Move(){Console.Write(Console.Write("Move!");)} }
C: abstract class Cat: Animal { public void Move(){Console.Write(Console.Write("Move!");)}; }
D: abstract class Cat: Animal { public void Eat(){Console.Write(Console.Write("Eat!");)}; }
A: abstract class Cat: Animal { abstract public void Move(); }
B: abstract class Cat: Animal { virtual public void Move(){Console.Write(Console.Write("Move!");)} }
C: abstract class Cat: Animal { public void Move(){Console.Write(Console.Write("Move!");)}; }
D: abstract class Cat: Animal { public void Eat(){Console.Write(Console.Write("Eat!");)}; }
举一反三
- 请阅读下面的程序,写出运行结果,如果编译失败,写明失败原因。 abstract class Animal{ public final abstract void eat(); } class Cat extends Animal{ public void eat(){ System.out.println("cat...fish"); } } class CatDemo{ public static void main(String[] args){ Animal a = new Cat(); a.eat(); } }
- 下面关于抽象类定义合法的是( ) A: class Animal { abstract void grow(); } B: abstract Animal { abstract void grow(); } C: class abstract Animal { abstract void grow(); } D: abstract class Animal { abstract void grow(); }
- 下列抽象类的定义合法的是( )。 A: abstract Animal {abstract void growl();} B: abstract class Animal {abstract void growl();} C: class abstract Animal {abstract void growl();} D: abstract class Animal {abstract void growl() {System.out.println(“growl”);}}
- 下列类定义中哪些是合法的抽象类的定义? A: abstract Animal{abstract void grow();} B: class abstract Animal{abstract void growl();} C: abstract class Animal{abstract void growl();} D: abstract class Animal{abstract void grow(){System.out.println("growl")};
- 下列类定义中()是合法的抽象类的定义。 A: abstract<br/>Animal {abstract void growl();} B: abstract<br/>class Animal {<br/>abstract<br/>void growl() { System.out.println(“growl”);}<br/>} C: class<br/>abstract Animal {abstract void growl();} D: abstract<br/>class Animal {abstract void growl();}