给定代码如下: public abstract interface Frobnicate { public void twiddle(String s); } 以下哪个类是正确的?().
A: public abstract class Frob implements Frobnicate { public abstract void twiddle(String s) { } }
B: public abstract class Frob implements Frobnicate { }
C: public class Frob extends Frobnicate { public void twiddle(Integer i) { } }
D: public class Frob implements Frobnicate { public void twiddle(Integer i) { } }
A: public abstract class Frob implements Frobnicate { public abstract void twiddle(String s) { } }
B: public abstract class Frob implements Frobnicate { }
C: public class Frob extends Frobnicate { public void twiddle(Integer i) { } }
D: public class Frob implements Frobnicate { public void twiddle(Integer i) { } }
举一反三
- 请阅读下面的程序,写出最终的结果: interface Inter { public void show(); } abstract class AbstractInter implements Inter { public void show() { System.out.println("AbstractInter show()"); } } class InterImpl extends AbstractInter { public void show() { System.out.println("InterImpl show()"); } } public class InterImplTest { public static void main(String[] args) { InterImpl i = new InterImpl(); i. show(); } }
- 下列哪个方法可用于创建一个可运行的类X? A: public class X implements Runnable{ public void run(){......} } B: public class X implements Thread{ public void run(){......} } C: public class X implements Thread{ public int run(){......} } D: public class X extends Runnable{ public void run(){......} }
- 下列关于Test类的定义代码中,正确的是______。 A: class Test implements Runnable { public void run() {} public void someMethod() {} } B: class Test implements Runnable { public void run(); } C: class Test implements Runnable { public void someMethod(); } D: class Test implements Runnable { public void someMethod() {} }
- 以下程序的编译和运行结果为? abstract class Base{ abstract public void myfunc(); public void another(){ System.out.println("Another method"); } } public class Abs extends Base{ public static void main(String argv[]){ Abs a = new Abs(); a.amethod(); } public void myfunc(){ System.out.println("My Func"); } public void amethod(){ myfunc(); } }
- 下列哪个方法可用于创建一个可运行的类() A: public class X implements Runnable{public void run() {……}} B: public class X extends Thread{public void run() {……}} C: public class X extends Thread{public int run() {……}} D: public class X implements Runnable{protected void run() {……}}