版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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 currentTime = new Date();try sleep(1000);catch (Exception e) String dateString = formatter.format(currentTime);System.out.println(getName()+:+dateString); public stat
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 防止烫伤预防和自救方法
- 2025版冠状动脉粥样硬化常见症状及护理策略培训
- 中医科普文化巡讲
- 患者家属陪床宣教
- 新员工安全教育培训
- 2025版心力衰竭症状分析及护理要点
- 血透内瘘养护宣教
- 液压考试题库及答案解析2025版
- 2024年少年儿童心理健康知识竞赛题库(含答案)
- 2025版泌尿系统疾病症状解析及护理培训
- 2025河南农商银行金融科技人才常态化招聘考试参考试题及答案解析
- 2025年船舶建造合同协议样本
- 工业高质量数据集研究报告 2025 中国工业互联网研究院
- 2025江苏苏州市姑苏区劳动人事争议仲裁院协理员招聘5人考试参考试题及答案解析
- 全面流程审计管理模板
- GB/T 45817-2025消费品质量分级陶瓷砖
- JJG 693-2011可燃气体检测报警器
- 酒店用品设备采购投标方案(技术方案)
- 顶管顶进施工方案2
- 二甲医院麻醉科相关工作制度汇编
- 麻醉术前术后访视记录单
评论
0/150
提交评论