首页 > 计算机等级考试
题目内容 (请给出正确答案)
[主观题]

(24 )请阅读下面程序public class ThreadTest {public static void main (String args[ ]){Thr

(24 )请阅读下面程序

public class ThreadTest {

public static void main (String args[ ]){

Thread t1 = new Thread (new Hello ()):

Thread t2 = new Thread (new Hello ()):

t l .start ():

t2.start ();

class Hello implements Runnable {

int i ;

public void run (){

while (true ) {

System.out.println ("Hello"+i++ ) ;

if (i=5 ) break :

}

该程序创建线程使用的方法是()

A )继承 Thread 类

B )实现 Runnable 接口

C ) t l.start ()

D ) t2.start ()

查看答案
答案
收藏
如果结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能还需要:
您的账号:
发送账号密码至手机
发送
安装优题宝APP,拍照搜题省时又省心!
更多“(24 )请阅读下面程序public class Threa…”相关的问题
第1题
阅读下面程序public class Test2{public static void main(String args[]){int a=10,b=4,c=

阅读下面程序

public class Test2{

public static void main(String args[]){

int a=10,b=4,c=20,d=6;

System.out.println(a++*b+c*-d);

}

}

程序运行的结果是

A)144

B)160

C)140

D)164

点击查看答案
第2题
阅读下面程序public class Test3{public static void main(String args[]){int x=3,y=4,z=5

阅读下面程序

public class Test3{

public static void main(String args[]){

int x=3,y=4,z=5;

String s= " xyz " ;

System.out.println(s+x+y+z);

}

}

程序运行的结果是

A)xyz12

B)xyz345

C)xyzxyz

D)12xyz

点击查看答案
第3题
(18 )请阅读下面程序/.public class ForLoopStatement {public static void main (String[] ar

(18 )请阅读下面程序/.

public class ForLoopStatement {

public static void main (String[] args ){

int I,j :

for (i=l;i<5;i++ ){ //i 循环

for (j=1;j<=i;j++ ) //j 循环

System.out.print (i+" X "+j+ ” = +i*j+" ” );

System.out.println () ;

}

程序完成后, i 循环和 j 循环执行的次数分别是

A ) 4 , 10

B ) 8 , 9

C ) 9, 8

D ) 10 , 10

点击查看答案
第4题
阅读下面程序public class Test2 { public static void main(String[] args) { int a=10,b=4.c=

阅读下面程序 public class Test2 { public static void main(String[] args) { int a=10,b=4.c=20,d=6; System.out.println(a++*b+c*--d); } } 程序运行的结果是

A.144

B.160

C.140

D.164

点击查看答案
第5题
(15 )阅读下面程序public class Test1{public static void main(String[] args){System.out.pri

(15 )阅读下面程序

public class Test1{

public static void main(String[] args){

System.out.println(34 + 56 - 6);

System.out.println(26*2 - 3);

System.out.println(3 * 4/2);

System.out.println(5/2);

}

}

程序运行结果是

A ) 84

49

6

2

B ) 90

25

6

2.5

C ) 84

23

12

2

D ) 68

49

14

2.5

点击查看答案
第6题
(17 )阅读下面程序public class OperatorsAndExpressions {void equalsMethod1(){String s1=new

(17 )阅读下面程序

public class OperatorsAndExpressions {

void equalsMethod1(){

String s1=new String("how are you");

String s2=new String("how are you");

System.out.println(s1==s2);

}

public static void main(String args[]){

OperatorsAndExpressions perAndExp=new OperatorsAndExpressions();

// 用于复合类型数据的 “ == ” 运算符

OperAndExp. equalsMethod1();

}

}

程序运行结果是

A ) ==

B ) true

C ) false

D ) equal

点击查看答案
第7题
阅读下面程序public class Test1 {public static void main(String[] args) { System.out.printl

阅读下面程序 public class Test1 { public static void main(String[] args) { System.out.println(34+56-6); System.out.println(26*2-3); System.out.println(3*4/2); System.out.println(5/2); } } 程序运行的结果是

A.84 49 6 2

B.90 25 6 2.5

C.84 23 12 2

D.68 49 14 2.5

点击查看答案
第8题
请阅读下面程序import java.io. *;public class TypeTransition {public static void main(Strin

请阅读下面程序 import java.io. *; public class TypeTransition { public static void main(String args[]){ char a='a'; int i=l00; long y=456L; int aa=a+i; long yy=y-aa; System.out.print("aa = "+a

A.aa=197 yy=259

B.aa=177 yy=259

C.aa=543 yy=288

D.aa=197 yy=333

点击查看答案
第9题
请阅读下面程序public class Test {public static void main (String[] args) {int i,j;for (i=1

请阅读下面程序

public class Test {

public static void main (String[] args) {

int i,j;

for (i=1;i<5;i++) {

for (j=1;j<=i;j++)

system.out.print (i+"X"+j+"="+i*j+" ");

System.out.println();

}

}

}

程序执行完后,i循环和j循环执行的次数分别是【 】。

点击查看答案
第10题
(28 )请阅读下面程序public class ThreadTest {public static void main (String args[ ]) thr

(28 )请阅读下面程序

public class ThreadTest {

public static void main (String args[ ]) throws Exception {

int i=0;

Hello t = new Hello ();

___________;

whlle (true ){

System.out.println ("Good Morning"+i++ ) ;

if (i=2 && t.isAlive ()){

System.out.println ("Main waiting for Hello ! ” );

tjoin () ; // 等待 t 运行结束

if (i==5 ) break :}

}

class Hello extends Thread {

int i ;

public void run ()笼

while (true ){

System.out.println ("Hello"+i++ ) ;

if (i=5 ) break ;}}}

为使该程序正确执行,下划线处的语句应是

A ) t.sleep ()

B ) t.yieldn ()

C ) t.interrupt ()

D ) t.start ()

点击查看答案
退出 登录/注册
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改