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() {……}}
举一反三
- 下列哪个方法可用于创建一个可运行的类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() {} }
- class X implements Runnable{public static void main(String args[]){/* Missing code? */}public void run() {}}哪一行代码适合启动线程? A: Thread t = new Thread(X); B: Thread t = new Thread(X);t.start(); C: X run = new X();Thread t = new Thread(run);t.start(); D: Thread t = new Thread();x.run();
- Given: 1. public class Foo implements Runnable { 2. public void run (Thread t) { 3. System.out.println("Running."); 4. } 5. public static void main (String[] args) { 6. new Thread (new Foo()).start(); 7. } 8. } What is the result?
- 现有 public class Parent{ public void change (int x){ } } public class Child extends Parent{ //覆盖父类change方法 }下列哪个声明是正确的覆盖了父类的change方法? A: protected void change (int x){} B: public void change(int x, int y){} C: public void change (int x){} D: public void change (String s){}
内容
- 0
public class Parent{ public void change(int x){} } public class Child extends Parent{ //覆盖父类change方法 } 下列哪个声明是正确的覆盖了父类的change方法?() A: protected void change(int x){} B: public void change(int x, int y){} C: public void change(String s){} D: public void change(int x){}
- 1
interface A{ void x(); } class B implements A{ public void x(){} public void y(){} } class C extends B{ public void x(){System.out.println("C");} } public class Test{ public static void main(String args[]){ B b=new B(); B c=new C(); b.x(); c.y(); } } A: 程序运行错误 B: 程序没有输出结果 C: 程序输出C。 D: class B implements A 编译错误 E: c.y();编译错误
- 2
给定代码如下: 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) { } }
- 3
下列程序运行结果是( ) 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..."); } }
- 4
下列程序创建了一个线程并运行,请在下画线处填入正确代码。 public class Try extends Thread public static void main(String args[]) Thread t=new Try(); ______; public void run() System.out.printin("Try!");