ImageVerifierCode 换一换
格式:DOCX , 页数:21 ,大小:20.86KB ,
资源ID:5861571      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/5861571.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(java复习题答案.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

java复习题答案.docx

1、java复习题答案复习题1一、 选择题答案 选择第1题B选择第2题A选择第3题C选择第4题B选择第5题A选择第6题A选择第7题B选择第8题C选择第9题B选择第10题B选择第11题C 二、多项选择题答案 多项选择第1题BD多项选择第2题AE多项选择第3题AC多项选择第4题AE多项选择第5题AE多项选择第6题DEF多项选择第7题AC多项选择第8题BC多项选择第9题AB多项选择第10题CD多项选择第11题CD多项选择第12题ACD多项选择第13题ABD 三、 填空题答案 填空第1题x=10,a=3,b=4,c=5填空第2题java.util填空第3题(public )(static )(void)(

2、main)(String args)填空第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.drawS

3、tring(s,25,25);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-

4、1j-1+yanghuii-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 13im

5、port java.io.*;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

6、s)trybw.write(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;publ

7、ic static void 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.equalsIgnoreCa

8、se(new String(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 (

9、ilineLength-1)&(b=System.in.read()!=n)linei+ = (byte)b; linei=(byte) 0; 复习题2四、 编程题答案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

10、 World!;public void paint(Graphics g)g.drawString(s,25,25);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

11、=1;jyanghuii.length-1;j+)yanghuiij=yanghuii-1j-1+yanghuii-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

12、 70 56 28 8 1 1 9 36 84 126 126 84 36 9 13import java.io.*;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(FileNotFoundExceptio

13、n e);public synchronized void append(String s)trybw.write(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;

14、public static final int lineLength = 81;public static void 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

15、quit);readLine(name);if (done.equalsIgnoreCase(new String(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 l

16、ine) throws IOException int i=0,b=0; while (ilineLength-1)&(b=System.in.read()!=n)linei+ = (byte)b; linei=(byte) 0; 二、多项选择题答案 多项选择第1题ACD多项选择第2题AB多项选择第3题AD多项选择第4题CD多项选择第5题AD多项选择第6题AC多项选择第7题AD多项选择第8题BC多项选择第9题BD多项选择第10题BCD多项选择第11题BD多项选择第12题ABD多项选择第13题BD多项选择第14题ABD 三、 填空题答案 填空第1题Collection,List,Map,Set填

17、空第2题7填空第3题因为在A的main方法中,还没有A的实例就要试图生成内部类的实例 四、 编程题答案编程第1题import java.io.*;public class Pointint x,y;public Point(int x,int y)this.x = x;this.y = y;public Point getPoint()Point tempPoint = new Point(x,y);return tempPoint;public void setPoint(Point point)this.x = point.x;this.y = point.y;public static

18、void main(String args)Point Point1 = new Point(3,4);System.out.println(Point1:+(+Point1.x+,+Point1.y+);Point Point2 = Point1.getPoint();System.out.println(Point2:+(+Point2.x+,+Point2.y+);Point Point3 = new Point(5,6);Point1.setPoint(Point3);System.out.println(Point1:+(+Point1.x+,+Point1.y+); 编程第2题im

19、port java.io.*;class FileCopypublic static void main(String args)FileInputStream in;FileOutputStream out;if (args.length2)System.out.println(Usage: java copy srcfile destfile);System.exit(-1); try in = new FileInputStream(args0);out = new FileOutputStream(args1);copyFile(in,out);catch (Exception e)S

20、ystem.out.println(e);private static void copyFile(FileInputStream in, FileOutputStream out)int length;byte buf = new byte1024;trywhile (length=in.read(buf,0,1024)!=-1)out.write(buf, 0, length); catch (Exception e)System.out.println(Error:+e);System.exit(-1);编程第3题import java.awt.*;import java.awt.eve

21、nt.*;import java.applet.*;import java.util.*;public class TimeViewer extends Applet implements ActionListener, Runnable Thread timer;TextField in, out;Button bb;Panel p1, p2, p3;boolean state;public void init() in = new TextField(20); out = new TextField(20);bb = new Button(Current Time:);p1 = new P

22、anel();p2 = new Panel();p3 = new Panel();setLayout(new GridLayout(3, 1);setSize(200,100);p1.add(in);p2.add(bb);p3.add(out);add(p1);add(p2);add(p3);bb.addActionListener(this); timer = new Thread(this);state = true;timer.start(); public void actionPerformed(ActionEvent e) /out.setText(in.getText();out

23、.setText(currentTime(); public void run() while(true) try timer.sleep(1000); catch (InterruptedException e) in.setText(currentTime();String currentTime() Date now = new Date();String str = now.getHours() + : + now.getMinutes() + : + now.getSeconds();return str;复习题3一、 选择题答案 选择第1题C选择第2题D选择第3题D选择第4题C选择第5题B选择第6题B选择第7题C选择第8题D选择第9题A选择第10题A选择第11题B选择第12题B 二、多项选择题答案 多项选择第1题AB多项选择第2题BD多项选择第3题ADE多项选择第4题AD多项选择第5题BCD多项选择第6题AB多项选择第7题ABCD多项选择第8题ABCD多项选择第9题BC多项选择第10题BC多项选择第11题AC 三、 填空题答案 填空第1题protected;default;public填空第2题Object填空第3题java.lang.Character;java.lang.Boolean填空第4题What a pleasure! I

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1