下列选项中,关于接口的定义正确的是?
A: abstract class Demo1{ abstract void speak(); abstract void eat(); }
B: interface Demo2{ void speak(); void eat(); }
C: interface Demo3{ void speak(); void eat(){}; }
D: interface Demo4{ void speak(){ System.out.println("ITCAST"); } void eat(); }
A: abstract class Demo1{ abstract void speak(); abstract void eat(); }
B: interface Demo2{ void speak(); void eat(); }
C: interface Demo3{ void speak(); void eat(){}; }
D: interface Demo4{ void speak(){ System.out.println("ITCAST"); } void eat(); }
举一反三
- 接口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!");)}; }
- 下列程序运行结果是( ) public class Demo { public static void main(String[] args) { Demo demo = new Demo(); demo.show(new Car() { public void run() { System.out.println("demo run"); } }); } public void show(Car c) { c.run(); } }abstract class Car { public void run() { System.out.println("car run..."); } }
- 1、以下接口定义,正确的是()。 A: interface A {void print(){};} B: abstract interface A {void print();} C: abstract interface A extends J1, J2{ //J1、J2是已定义的接口abstract void print(){};} D: interface A {void print();}
- 下面()是正确的接口定义。 A: interface A{void print(){};} B: abstract interface A extends I1,I2{abstract void print(){};} C: abstract interface A{print();} D: interface A {void print();}
- 下面()是正确的接口定义。 A: interface IGood{void print( ){ };} B: abstract interface IGood{print( );} C: abstract interface IGood{abstract void print( ){ };} D: interface IGood{void print( );}