单项选择题
public class Holt extends Thread{ private String sThreadName;
public static void main(String argv[]){
Holt h = new Holt();
h.go(); }
Holt(){}
Holt(String s){
sThreadName = s; }
public String getThreadName(){
return sThreadName; }
public void go(){
Holt first = new Holt("first");
first.start();
Holt second = new Holt("second");
second.start(); }
public void start(){
for(int i = 0; i < 2; i ++){
System.out.println(getThreadName() +i);
try{
Thread.sleep(100); }
catch(InterruptedException e){
System.out.println(e.getMessage());
}
} } }
当编译运行上面的Java代码时,将会出现()。
A.编译时错误
B.输出first0, second0, first0, second1
C.输出first0, first1, second0, second1
D.运行时错误
相关考题
-
多项选择题
public class test3 { public static void main(String args[]) { for(int i = 0; i < 3; i++) { for(int j = 3; j >= 0; j--) { if(i == j) continue; System.out.println("i="+ i + " j="+j); } } } } 上面的Java代码编译运行后,下列选项中,()会出现在输出结果中。
A.i=0 j=3
B.i=0 j=0
C.i=2 j=2
D.i=0 j=2
E.i=1 j=2 -
多项选择题
import java.awt.*; import java.applet.*; public class ButtonDemo extends Applet{ public void init() { Button pushBotton=new Button("ok"); Button downBotton=new Button("Yes"); add(pushBotton); add(downBotton); } } 根据以上代码,下列解释正确的是()。
A.该代码画了一个按钮
B.Button("ok")创建一个有显示"ok"的按钮
C.Button()是构造函数
D.按钮属于容器 -
单项选择题
返回按钮的标签的方法的是()。
A.getActionCommand()
B.setLabel(string str)
C.button()
D.getLabel()
