题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2023-10-05 18:30:07

[填空题]通过实现Runnable接口创建线程,请在画线处加入正确的代码完成此程序______。
publicclass ThreadTest

publicstaticvoid main(Stringargs[])

Threadt1=newThread(newHello( )):
Threadt2=newThread(newHellO( ));
T2.start( );


classHelloimplementsRunnable

intI;
publicvoidIUB( )

while(true)

System.out.println(“Hello”+i++);
If(i==5)break;



更多"通过实现Runnable接口创建线程,请在画线处加入正确的代码完成此程"的相关试题:

[填空题]通过实现Runnable接口创建线程,请在画线处加入正确的代码完成此程序 【9】
public class ThreadTest

public static void main(String args[ ]

Thread t1 = new Thread(new Hello( )
Thread t2 = new Thread(new Hello( )
___________;
t2.start( );


class Hello implements Runnable

int i;
public void run( )

while (true)

System.out.println("Hello"+i++
if(i==5) break;



[填空题]通过实现Runnable接口创建线程,请在画线处加入正确的代码完成此程序______。 publicclass ThreadTest { publicstaticvoid main(Stringargs[]) { Threadt1=newThread(newHello( )): Threadt2=newThread(newHellO( )); T2.start( ); } } classHelloimplementsRunnable { intI; publicvoidIUB( ) { while(true) { System.out.println(“Hello”+i++); If(i==5)break; } } }
[填空题]通过实现Runnable接口创建线程,请在画线处加入正确的代码完成此程序_________。
public class ThreadTest

public static void main(String args[])

Thread t1=new Thread(new Hello( )):
Thread t2=new Thread(new Hello( ));
________;
t2.start( );


class Hello implements Runnable

int i;
public void run( )

while(true)

System.out.println("Hello"+i++);
If(i==5) break:



[填空题]通过实现Rmmable接口创建线程,请在下面横线处填写代码完成此程序。 public class ThreadTest { public static void main(String args []) { Thread testObj1 = new Thread (new Hello ( )); Thread testObj2 = new Thread (new Hello ( )); testObj 2.start ( ); } } class Hello implements Runnable { int j; public void run( ) { System.out.println("Hello" + j ++); } }
[简答题]通过实现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( )+":"+"在运行!"); } }
[简答题]通过实现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( )+":"+"在运行!");


[填空题]从对象流中读取对象,请在画线处加入代码完成此程序 【10】 。 import java.util.*; import java.io.*; public class UnSerializeDate { Date d = null; UnSerializeDate( ) { try{ FileInputStream f = new FileInputStream("data.ser"); ______; d = (Date) s.readObject( ); f.close( ); } catch(Exception e) { e.printStackTrace( ); } } public static void main(String args[ ]) { UnSerializeDate a = new UnSerializeDate( ); System.out.println("The date read is :"+a.d.toString( )); } }
[填空题]从对象流中读取对象,请在画线处加入代码完成此程序 【10】
import java.util.*;
import java.io.*;
public class UnSerializeDate

Date d = null;
UnSerializeDate( )

try
FileInputStream f = new FileInputStream("data.ser");
______;
d = (Date) s.readObject( );
f.close( );

catch(Exception e)

e.printStackTrace( );


public static void main(String args[ ])

UnSerializeDate a = new UnSerializeDate( );
System.out.println("The date read is :"+a.d.toString( ));


[单项选择]下列程序通过实现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(m
B. new Thread()
C. new Thread(m
D. Thread(m
[单项选择]下列程序从标准输入设备——键盘读入一个字符,然后输出到屏幕。要想完成此功能,画线处应该填入的语句为______。
import java. io. * ;
public class Test

public static void main(String args[])

char ch;
try

______;
System. out. println(ch);

catch(IOException e)

e. printStackTrace( );


A. ch=System. in. read();
B. ch=(char)System. in. read();
C. ch=(char)System. in. readln();
D. ch=(int)System. in. read();
[单项选择]下列程序从标准输入设备——键盘读入一个字符,然后再输出到屏幕。要想完成此功能,画线处应该填入的语句为( )。
import java.io.*;
public class Test

public static void main(String args[ ])

char ch;
try

______;
System.out.println(ch);

catch(IOException e)

e.printStackTrace( );



A. ch= System.in.read();
B. ch=(char)Systcm in.read();
C. ch=(char)System.in.readln();
D. ch=(int)System in.read();

我来回答:

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

订单号:

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