题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-01-05 20:10:11

[单项选择]阅读下面程序:
public class ThreadTest
 public static void main(String args[]) throws Exception
  int i=0;
  Hello t=new Hello( );
  ______;
  While(true)
   System.out.println("Good Morning"+i++);
   if(i==2&&t.isAlive( ))
    System.out.println("Main waiting for Hello!");
    t.join( ); //等待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. sleep()
B. yield()
C. interrupt()
D. start()

更多"阅读下面程序: public class ThreadTest "的相关试题:

[单项选择]请阅读下面程序
public class ThreadTest
public static void main(String args[])throws Exception
int i=0:
Hello t=new Hello( );
_________;
while(true)
System.out.println("Good Morning"+i++);
if(i==2&&t.isAlive( ))
System.out.println("Main waiting for Hello!");
t.join( );//等待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. sleep()
B. yield()
C. interrupt()
D. start()
[单项选择]阅读下面程序
public cmass ThreadTest
 public static void main(String args[])
  Thread t1=new Thread(new Hello( ));
  Thread t2=new Thread(new Hello( ));
  t1.start( );
  t2.start( );
 

class Hello implements Runnable
 int i;
 public void run( )
  while(true)
   System.out.println("Hello"+i++);
   it(i==5) break;
  
 

此程序创建线程所使用的方法是
A. 继承Thread类
B. 实现Runnable接口
C. t1.start()
D. t2.start()
[单项选择]阅读下面程序: public class ThreadTest {  public static void main(String args[]) throws Exception {   int i=0;   Hello t=new Hello( );   ______;   While(true) }    System.out.println("Good Morning"+i++);    if(i==2&&t.isAlive( )) {     System.out.println("Main waiting for Hello!");     t.join( ); //等待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.yield()
C. t.interrupt()
D. t.start()
[单项选择]

请阅读下面程序
public class ThreadTest{
public static void main(String args[]) {
Thread t1=new Thread(new Hello( ));
Thread t2=new Thread(new Hello( ));
t1.start( );
t2.start( );
}
}
class Hello implements Runnable {
int i;
public void run( ) {
while(true) {
System.out.prinfin("Hello"+i++);
if(i=5) break;
}
}
}
该程序创建线程使用的方法是()


A. 继承Thread类
B. 实现Runnable接口
C. t1.start()
D. t2.start()
[单项选择]

请阅读下面程序
public class ThreadTest {
public static void main(String args[]) throws Exception{
int i=0;
Hello t=new Hello( );
____;
while(true) {
System.out.println("Good Moming"+i++);
if (i==2 && t.isAlive( )) {
System. out.println("Main waiting for Hello!");
t.join( ); //等待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. sleep()
B. yield()
C. interrupt()
D. start()
[单项选择]阅读下面程序 public cmass ThreadTest {  public static void main(String args[]) {   Thread t1=new Thread(new Hello( ));   Thread t2=new Thread(new Hello( ));   t1.start( );   t2.start( );  } } class Hello implements Runnable {  int i;  public void run( ) {   while(true) {    System.out.println("Hello"+i++);    it(i==5) break;   }  } } 此程序创建线程所使用的方法是
A. 继承Thread类
B. 实现Runnable接口
C. t1.start()
D. t2.start()
[单项选择]请阅读下面程序   public class ThreadTest{   public static void main(String args[])throws Ex-   ception{   int i=0;   Hello t=new Hello( );   ;   while(true){   System.Out.println("Good Morning"+i++):   if(i= =2&&t.isAlive( )){   System.out.println("Main waiting for Hel-   lo!");   t.join( );//等待t运行结束   }   if(i= =5)break;}   }   }   class Hello extends Thread{      int l;   public void run( ){   while(true)(   System.Out.println("Hell0"+i++);   if(i= =5)break;)))   为使该程序正确执行,下画线处的语句应是( )。
A. t.sleep()
B. t.yield()
C. t.interrupt()
D. t.start()
[单项选择]阅读下列程序:
class ThreadTest extends Thread
public static void main(String[]args)
Thread t=new Thread(this);
t.start( );

public void run( )
System.out.print("A thread test.");
对该程序而言,正确结论是 ( )
A. 该程序能够通过编译并打印输出“A thread test.”
B. 该程序能够通过编译,但运行时将不调用ThreadTest类中的run()方法,因此不产生任何输出
C. 该程序存在编译错误,因为在main()方法中不能使用this指针
D. 上述选项都不正确
[单项选择]阅读下面程序
public class Increment
 public static void main(String args[])
  int c;
  c=5;
  System.out.println(C) ;
  System.out.println(c++);
  System.out.println(C) ;
 

程序运行的结果是
A. 5
B. 5
C. 6
D. 6
[单项选择]阅读下面程序
public class Increment
public static void main (String args[]
int c;
c=5;
System.out.printIn(c);
System.out.printIn(c++)j
System.out.printIn (c);


程序运行结果是______。
A. 5
B. 5
C. 6
D. 6
[单项选择]阅读下面程序
public class ConcatTest
 public static void main(String[] args)
  String str1="abc";
  String str2="ABC":
  String str3=str1.concat(str2);
  System.out.println(str3);
 

程序运行的结果是
A. abc
B. ABC
C. abcABC
D. ABCabc
[单项选择]阅读下面程序 public class VariableUse {  public static void main(String[] arqs) {   int a;   if(a==8) {    int b=9;    System.out.println("a="+a);    System.out.println("b="+b);   }   System.out.println("a="+a);   System.out.println("b="+b):  } } 该程序在编译时的结果是
A. 变量a未赋值
B. 第二个System.out.println("b="+b);语句中,变量b作用域有错
C. 第二个System.out.println("a="+a);语句中,变量a作用域有错
D. 第一个System.out.println("b="+b);语句中,变量b作用域有错
[单项选择]阅读下面程序
public class MyVal
 public static void main(String[]args)
  MyVal m=new MyVal( );
  m.amethod( );
 
 public void amethod( )
  boolean b[]=new Boolean[5];
 

程序编译或运行的结果是
A. 1
B. null
C. ""
D. 编译不通过
[填空题]请阅读下面程序
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循环执行的次数分别是 【12】

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码