NTUE-CS103 板


LINE

1. 下列程式执行时会发生例外而中止执行,请在b=0及a/b不变的情况下,修改本程式使 不会因例外发生而中断执行。(10%) public class app { public static void main(String args[]) { int a=4,b=0; System.out.println(a+"/"+b+"="+a/b); } } - 2. 简单说明 public, private 及 protected 对类别成员及建构元存取的作用。(10%) - 3. 下列程式执行的结果会不正确,请说明原因及如何修正。(10%) class CBank { private static int sum=0; public static void add(int n) { int tmp=sum; tmp=tmp+n; try { Thread.sleep((int)(1000*Math.random())); } catch(InterruptedException e){} sum=tmp; System.out.println("sum= "+sum); } } class CCustomer extends Thread { public void run() { for(int i=1;i<=3;i++) CBank.add(100); } } public class app { public static void main(String args[]) { CCustomer c1=new CCustomer(); CCustomer c2=new CCustomer(); c1.start(); c2.start(); } } - 4. 下面的程式希望产生乱数并将其写到档案 randow.txt,但实际执行时 random.txt并 没有存下任何内容,请说明如何修改程式使执行结果正确。(10%) import java.io.*; public class app { public static void main(String args[]) { try { FileWriter fw=new FileWriter("c:\\random.txt"); BufferedWriter bfw=new BufferedWriter(fw); for(int i=1;i<=5;i++) { bfw.write(Double.toString(Math.randow())); bfw.newLine(); } fw.close; } catch(IOException e){} } } - 5. 请简要说明 Java 的"委派事件模式"的运作流程。(10%) - 6. 若一个视窗物件其中包含一个按钮 (button) 物件及一个功能表的 MenuItem 物件, 这两个物件均会触发 ActionEvent 事件,假设有一个ActionEvent 事件被触发,请说 明如何设计程式使能区分是由何物件所触发。(10%) - 7. 以 Java 绘图时,若需要重画时常会呼叫 update(),但是若图形会移动且呼叫很频繁 时会感觉会面闪烁,请说明其原因及解决方式。(10%) - 8. 下列程式希望按按钮时会将视窗的背景颜色改为黄色,但程式尚有欠缺,请予以完成 。(10%) import java.awt.*; import java.awt.event.*; public class app extends Frame implements ActionListener { static app frm=new app(); static Button btn=new Button("Click Me"); public static void main(String args[]) { btn.addActionListener(frm); frm.setLayout(new FlowLayout()); frm.setTitle("Action Event"); frm.setSize(200,150); frm.setBackground(Color.blue); frm.add(btn); frm.setVisible(true); } } - 9. 简单注解下列程式加底线粗体部分其意义。(10%) (这里用红字代替底线粗体) import java.net.*; import java.io.*; public class app { public static void main(String args[]) { try { ServerSocket svs=new ServerSocket(2525); // Socket s=svs.accept(); // OutputStream out=s.getOutputStream(); String str="Honor shows the man."; out.write(str.getBytes()); out.close(); s.close(); // } catch(Exception e){} } } - 10. 请简单画出下面 applet 及 html 程式合并执行的结果。(10%) import java.awt.*; import java.applet.Applet; public class App extends Applet { public void paint(Graphics g) { g.drawString(getParameter("str1"),30,40); g.drawString(getParameter("str2"),30,60); } } <APPLET CODE = "App.class" WIDTH = "250" HEIGHT = "120" > <PARAM NAME = "str1" VALUE = "Repentance is a bitter physic." > <PARAM NAME = "str2" VALUE = "Laughter is the best medicine." > </APPLET> -- 不知道有没有打错或其他什麽的问题 之後有空再排版吧 系学会考古题快更新吧 嘿嘿 --



※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 120.127.47.94
1F:推 NTUE:十二万分感谢你体谅迷有脸书的人 (〒皿〒) 12/17 08:22
2F:→ andy801119:发在这边有人看的感觉真好 12/19 03:22
3F:推 bennyt6182:没有问题 12/20 03:39
4F:推 dosomethnig:谢拉 12/21 16:11







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:Gossiping站内搜寻

TOP