Java面向对象程序设计试题一答案.doc

上传人:飞****2 文档编号:52205816 上传时间:2022-10-21 格式:DOC 页数:6 大小:21.50KB
返回 下载 相关 举报
Java面向对象程序设计试题一答案.doc_第1页
第1页 / 共6页
Java面向对象程序设计试题一答案.doc_第2页
第2页 / 共6页
点击查看更多>>
资源描述

《Java面向对象程序设计试题一答案.doc》由会员分享,可在线阅读,更多相关《Java面向对象程序设计试题一答案.doc(6页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、Java面向对象程序设计试题一答案一、单项选择题:选择第1题:B选择第2题:A选择第3题:C选择第4题:B选择第5题:A选择第6题:A选择第7题:B选择第8题:C选择第9题:B选择第10题:B二、多项选择题多项选择第1题:AB多项选择第2题:BD多项选择第3题:AD多项选择第4题:AD多项选择第5题:BCD多项选择第6题:AB多项选择第7题:ABCD多项选择第8题:ABCD多项选择第9题:BC多项选择第10题:BC三、 填空题答案 填空第1题:x=10,a=3,b=4,c=5填空第2题:java.util填空第3题:(public )(static )(void)(main)(String a

2、rgs)填空第4题:1填空第5题:26 四、 编程题答案1public class HelloWorldpublic static void main(String args)System.out.println(Hello,World!);import java.awt.Graphics;import java.applet.Applet;public class HelloWorld extends AppletString s;public void init()s=Hello World!;public void paint(Graphics g)g.drawString(s,25,2

3、5);2class yanghuipublic static void main (String args)int i,j;int yhlevel=10;int yanghui;System.out.println(杨晖三角形:);yanghui=new intyhlevel;for(i=0;iyanghui.length;i+)yanghuii=new inti+1;yanghui00=1;for (i=1; iyanghui.length;i+)yanghuii0=1;for(j=1;jyanghuii.length-1;j+)yanghuiij=yanghuii-1j-1+yanghui

4、i-1j;yanghuiiyanghuii.length-1=1;for (i=0; iyanghui.length;i+)for(j=0;jyanghuii.length;j+)System.out.print(yanghuiij+ );System.out.println(); 输出结果是:杨晖三角形:1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 1 6 15 20 15 6 1 1 7 21 35 35 21 7 1 1 8 28 56 70 56 28 8 1 1 9 36 84 126 126 84 36 9 13import java.io

5、.*;public class MemoControllerFileOutputStream fos;OutputStreamWriter osw;BufferedWriter bw;public MemoController()tryfos=new FileOutputStream(memo.txt,true); osw=new OutputStreamWriter(fos);bw=new BufferedWriter(osw);catch(FileNotFoundException e);public synchronized void append(String s)trybw.writ

6、e(s,0,s.length(); bw.flush();bw.close();osw.close();fos.close();catch(IOException e)public static void main(String args)MemoController mmc=new MemoController();mmc.append(I am xubin );4import java.io.*; class Phones static FileOutputStream fos;public static final int lineLength = 81;public static vo

7、id main(String args) throws IOExceptionbyte phone = new bytelineLength;byte name = new bytelineLength;int I;try fos = new FileOutputStream(phone.numbers);catch(FileNotFoundException e) while (true)System.err.println(Enter a name (enter done to quit);readLine(name);if (done.equalsIgnoreCase(new Strin

8、g(name,0,0,4)break; System.err.println(Enter the phone number); readLine(phone);for (int i=0;phonei!= 0;i+) fos.write(phonei);fos.write(,);for (int i=0;namei!= 0;i+)fos.write(namei); fos.write(n);fos.close(); private static void readLine(byte line) throws IOException int i=0,b=0; while (ilineLength-

9、1)&(b=System.in.read()!=n)linei+ = (byte)b; linei=(byte) 0; 5、import java.util.*;import java.text.*; class ThreeTimeThread extends Threadpublic ThreeTimeThread(String str) super(str);public void run() while (true) SimpleDateFormat formatter = new SimpleDateFormat (yyyy.MM.dd G at hh:mm:ss z);Date cu

10、rrentTime = new Date();try sleep(1000);catch (Exception e) String dateString = formatter.format(currentTime);System.out.println(getName()+:+dateString); public static void main(String args) throws Exceptionnew ThreeTimeThread(first).start(); new ThreeTimeThread(second).start();new ThreeTimeThread(third).start();

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 教案示例

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com