下列哪些定义在接口中的方法是合法的?
A: static void A() { System.out.println("A"); }
B: final static void B();
C: void C() { }
D: private void D();
E: public abstract void E();
F: static void F();
G: void G();
A: static void A() { System.out.println("A"); }
B: final static void B();
C: void C() { }
D: private void D();
E: public abstract void E();
F: static void F();
G: void G();
举一反三
- 下列接口中标注的(A,B,C,D)中,哪两个是错误的?interface Takecare { protected void speakHello(); public abstract static void cry(); int f(); abstract float g(); } A: protected void speakHello(); B: public abstract static void cry(); C: int f(); D: abstract float g();
- 下列程序中注释的那个代码是错误的? abstract class Takecare{ protected void speakHello() {} public abstract static void cry(); static int f(){return 0;} abstract float g(); } A: protected void speakHello() {} B: public abstract static void cry(); C: static int f(){return 0;} D: abstract float g();
- Which two declarations prevent the overriding of a method? () A: Final void methoda(){} B: Void final methoda(){} C: Static void methoda(){} D: Static final void methoda(){} E: Final abstract void methoda(){}
- 以下哪个是Java应用程序main方法的有效定义?() A: public static void main(); B: public static void main( intargs ); C: public static void main( String args[]); D: public static void main( Graphics g[]);
- 下面那个方法声明是正确的—— A: abstract final String doItYourSelf(){} B: public abstract doItYourself(){} C: private static void doItYourself(){} D: public abstract static void doItYourself(){}