0
1
2
3
第1题:
下列哪个方法可用于创建一个可运行的类? ( )
A.public class X implements Runable {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 implements Runable {protected void run(){.....}}
第2题:
下面程序段的输出结果是 class Test{ public static void main(String args[]){ MyThread t=new MyThread(); t.displayOutput("t has been created)); t.start(); } } class MyThread extends Thread{ public void displayOutput(String s){ System.out.println(s); } public void run(){ displayOutput(t is running."); } }
A.t has been created.
B.t has been created. t is running.
C.t is running.
D.编译出错
第3题:
下列关于Test类的定义中,正确的是( )。
A.class Test implements Runnable{ public void run{} Dublic void someMethod[]{} }
B.class Test implements Runnable( puIblic void run; }
C.class Test implements Runnable( Dublic void someMethod[]; }
D.class Test implements Runnable( public void someMethod{} }
第4题:
( 30 )在程序的下划线处应填入的选项是
public class Test _________{
public static void main(String args[]){
Test t = new Test();
Thread tt = new Thread(t);
tt.start();
}
public void run(){
for(int i=0;i<5;i++){
system.out.println( " i= " +i);
}
}
}
A ) implements Runnable
B ) extends Thread
C ) implements Thread
D ) extends Runnable
第5题:
class MyThread extends Thread { public void run() { System.out.println(“AAA”); } public void run(Runnable r) { System.out.println(“BBB”); } public static void main(String[] args) { new Thread(new MyThread()).start(); } } What is the result?()
第6题:
下列代码正确的是哪项?()
第7题:
现有: class ThreadBoth extends Threaa implements Runnable { public void run() (System.out.print("hi"); } public static voicl main (String [] args) { Thread tl=new ThreadBoth(): Thread t2 = new Thread (tl): tl.run(): t2.run(): } 结果为:()
第8题:
void run()
public void run()
public void start()
void run(int priority)
public void run(int priority)
public void start(int priority)
第9题:
0
1
2
3
第10题:
hi
hi hi
编译失败
代码运行,但无输出结果
第11题:
new Thread() { public void run() { doStuff(); } }
new Thread() { public void start() { doStuff(); } }
new Thread() { public void start() { doStuff(); } } .run();
new Thread() { public void run() { doStuff(); } } .start();
new Thread(new Runnable() { public void run() { doStuff(); } } ).run();
new Thread(new Runnable() { public void run() { doStuff(); } }).start();
第12题:
hi hi
hi
编译失败
运行时异常被抛出
第13题:
通过实现Runnable接口创建线程,请在下面横线处填入代码完成此程序。
注意:不改动程序结构,不得增行或删行。
class ThreadTest implements Runnable
{
Thread thrObj;
public static void main(String args[])
{
System.out.println("这是一个通过实现接口创建线程的例子");
ThreadTest testObj=new ThreadTest();
testObj.create();
}
public void create()
{
if(thrObj= =null)
{
thrObj=new Thread(this,"myThread");
______
}
}
public void run()
{
System.out.println("Thread"+throbj.getName()+":"+"在运行!");
}
}
第14题:
在下面程序的下画线处应填入的选项是 public class Test______{ public static void main(String args[]) { Test t=new Test(); Thread tt=new Thread(t); tt.start(); } public void run() { for(int i=0;i<5;i++) System.out.println("i="+i); } }
A.implements Runnable
B.extends Thread
C.implements Thread
D.extends Runnable
第15题:
下列程序通过实现Runnable接口创建一个线程,选择正确的语句填入程序的横线处。 class MyRun implements Runnable { String str; MyRun(String s) { str = s; } public void run() System.out.println(str); } } public class ex40 { public static void main(String[] args) { String name = "实现阶段Runnable 接口"; MyRun my = new MyRun(name); Thread th = th. start ( ); } }
A.new MyRun(my)
B.new Thread()
C.new Thread(my)
D.Thread(my)
第16题:
public class Threads3 implements Runnable { public void run() { System.out.print(”running”); } public static void main(String[] args) { Thread t = new Thread(new Threads3()); t.run(); t.run(); t.start(); } } What is the result?()
第17题:
interface Data { public void load(); } abstract class Info { public abstract void load(); } Which class correctly uses the Data interface and Info class?()
第18题:
Which method must be defined by a class implementing the java.lang.Runnable interface? ()
第19题:
Compilation fails.
An exception is thrown at runtime.
The code executes and prints “running”.
The code executes and prints “runningrunning”.
The code executes and prints “runningrunningrunning”.
第20题:
public class Session implements Runnable, Clonable{ public void run ();public Object clone () ; }
public class Session extends Runnable, Cloneable { public void run() {/*dosomething*/} public Object clone() {/*make a copy*/} }
public abstract class Session implements Runnable, Clonable { public void run() {/*do something*/} public Object clone() {/*make a copy*/} }
public class Session implements Runnable, implements Clonable { public void run() {/*do something*/} public Object clone() {/*make a copy*/} }
第21题:
public class Employee extends Info implements Data { public void load() { /*do something*/ } }
public class Employee implements Info extends Data { public void load() { /*do something*/ } }
public class Employee extends Info implements Data { public void load() { /*do something */ } public void Info.load() { /*do something*/ } }
public class Employee implements Info extends Data { public void Data.load() { /*dsomething */ } public void load() { /*do something */ } }
public class Employee implements Info extends Data { public void load() { /*do something */ } public void Info.load(){ /*do something*/ } }
public class Employee extends Info implements Data{ public void Data.load() { /*do something*/ } public void Info.load() { /*do something*/ } }
第22题:
0
1
2
3
第23题:
1
2
3
4
第24题:
AAA
BBB
Compilation fails.
The code runs with no output.