下列哪个方法可用于创建一个可运行的类()
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() {……}}
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){}