皮皮学,免费搜题
登录
logo - 刷刷题
搜题
【简答题】
请完成程序,首先由一个类simple实现Serializable接口,并有三个成员变量,分别为int型、double型和String型,可以用toString的方法显示这三个成员变量。在main方法中创建这个simple的持久对象,根据用户在命令行输入的三个参数来设定其中成员变量的值。然后,将这个对象写入名为TheSerial.data的文件中,并显示成员变量。最后从文件TheSerial.data中读出三个成员变量并显示出来。 注意:请勿修改main()主方法和其他已有语句内容,仅在横线处填入适当语句。 import java.io.*; class TheSerial implements Serializable { private int intvalue; private double doublevalue; private String string; The Serial () { intvalue=123; doublevalue=12.34; string='Serialize Test'; } public void setDouble(double d) { doublevalue=d; } public void setInt(int i) { intvalue=i; } public void setString(String s) { string=s; } public String to String() { return('int='+intvalue+' double='+doublevalue+' string='+string); } } public class simple { public static void main(String[] args) { The Serial e1=new TheSerial(); TheSerial e2; try { e1.setInt(Integer.parseInt(args[0])); e1.setDouble(Double.parseDouble(args[1])); e1.setString(args[2]); } catch(Exception e) { e1.setString(e.getMessage()); } System.out.println(e1); try { FileOutputStream S=new FileOutputStream('TheSerial.data'); ObjectOutputStream OS=new ObjectOutputStream(oS); ______; } catch(IOException ioException) { System.out.println (ioException.getMessage ()); } try { FileInputStream iS=new FileInputStream('TheSerial.data'); ObjectInputStream IS=new ObjectInputStream(iS); ______; System.out.println(e2); } catch(IOException ioException) { System.out.println(ioException.getMessage()); } catch(ClassNotFoundException cnfException) { System.out.println(cnfException.getMessage()); } } }
手机使用
分享
复制链接
新浪微博
分享QQ
微信扫一扫
微信内点击右上角“…”即可分享
反馈
参考答案:
举一反三
【简答题】It looked like a typical business meeting. Six men, neatly dressed in white shirts and ties filed into the boardroom of a small Jakarta company and sat down at a long table. But instead of consulting ...
【简答题】在七层的OSI模型关系上,路由器工作位于模型中的()层、HUB位于模型中的()层,相互通信的进程是在模型的()层建立连接的。
【单选题】The waters of the lake were so that it looked like glass .
A.
silent
B.
calm
C.
still
D.
quiet
【单选题】It looked like a typical business meeting. Six men, neatly dressed in white shirts and ties filed into the boardroom of a small Jakarta company and sat down at a long table. But instead of consulting ...
A.
Mysticism.
B.
Religion.
C.
Meditation.
D.
Investment.
【简答题】Meditation in Indonesian Business It looked like a typical business meeting. Six men, neatly dressed in white shirts and ties filed into the boardroom of a small Jakarta company and sat down at a long...
【单选题】The waterfall was running down from the high cliff so smoothly that it looked like a piece of silver cloth _______ from the sky.
A.
hanging back
B.
hanging down
C.
hanged
D.
hanged down
【简答题】连锁经营包括哪三种形式?
【单选题】It looked like a typical business meeting. Six men, neatly dressed in white shirts and ties, filed into the boardroom of a small Jakarta company and sat down at a long table. But instead of consulting...
A.
Mysticism.
B.
Religion.
C.
Meditation.
D.
Investment.
【多选题】连锁经营包括()
A.
特殊经营
B.
直营连锁
C.
特许经营
D.
自由连锁
【判断题】计量检定和计量校准都应发放合格证书或不合格通知书,作为计量器具合格与否的法定文件。()
A.
正确
B.
错误
相关题目:
参考解析:
知识点:
题目纠错 0
发布
创建自己的小题库 - 刷刷题