更多"从对象流中读取对象,请在画线处加入代码完成此程序 【10】 。 i"的相关试题:
[填空题]从对象流中读取对象,请在画线处加入代码完成此程序 【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( ));
[填空题]从对象流中读取对象,请在下面横线处填写代码完成此程序。
import java.util. *;
import java. io. *;
public class UnSerializeDate
{
date d = null;
UnSerializeDate ( )
{
try
{
FileInputStream f1 = new FileInputStream("date.ser");
d = (Date) s. readobject ( );
f1,close( );
}
catch (Exceptin e)
{
e. printStackTrace ( );
}
}
public static main(String args [] )
{
System.out.println("The date read is: "+ a.d.toString( ));
}
}
[填空题]通过实现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接口创建线程,请在画线处加入正确的代码完成此程序 【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接口创建线程,请在画线处加入正确的代码完成此程序______。
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:
[填空题]有如下代码片段,请在画线处填入正确的代码,使程序运行正确。
import javax.swing.*;
import java.awt.*;
import java.event.*;
public class JAppletTest extends 【12】 {
public void init( )
{
Container contentPane = getContentPane( );
Icon icon = new ImageIcon("swing.gif", "A GIF on a swing");
JLabel label = new JLabel("Swing!", icon, Swingconstants. CENTER);
contentPane.add(label, BorderLayout. CENTER);
}
}
[填空题]有如下代码片段,请在画线处填入正确的代码,使程序运行正确。
import javax.swing.*;
import java.awt.*;
import java.event.*;
public class JAppletTest extends 【12】 {
public void init( )
{
Container contentPane = getContentPane( );
Icon icon = new ImageIcon("swing.gif", "A GIF on a swing");
JLabel label = new JLabel("Swing!", icon, SwingConstants.CENTER);
contentPane.add(label, BorderLayout.CENTER);
}
}
[填空题]下面程序段是从对象流中读取对象,请将程序补充完整。
import java.util.*;
import java.io.*;
public class UnSerializaDate{
Date d=null;
UnSerializaDate( ){
try{
FilelnputStream f=new FilelnputStream("date.ser");
ObjectlnputStream S=new ObjectlnputStream(f);
【13】
f.close( );
}
catch(Exception e){
e.printStackTrace( );
}
}
public static void main(String args[]){
UnSerializaDate a=new UnSerializaDate( );
System.out.println("The date read is:"+a.d.toString( ));
}
)