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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

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

Java复习题三阅读程序题软件Word文档下载推荐.docx

1、3、阅读以下程序:public class TestRandomAccess public static void main(String args) int data_arr=65,66,56,23,27,1,43,65,4,99; RandomAccess RandomAccessFile(temp.dat,rw for (int i=0;data_arr.length; i+) randf.writelnt(data_arri); randf.writeUTF(Good morning! for(int i=data_arr.length-l; i=0; i=i-2) randf.see

2、k(i*4); System,out.print(+randf.readInt(); randf.seek(40); System.out.println(randf.readUTF(); randf.close(); catch (IOException e) System.out.println( error:+e);该程序的输出结果是:99 65 1 23 66 Good morning!4、阅读以下程序并填空。class _ extends Exception String mymsg=我自己定义的异常!; double mynum = 2.0; MyException () supe

3、r(首字母不能为A!); MyException (String msg)_ /调用父类构造方法,参数为 msg public void displayme() System.out.println(mymsg); public double mymethod() return Math.sqrt(mynum);class ExceptionTest public static void main(String args) try if ( argsO.charAt(O)= A) MyException e = new MyException();System.out.println(kkkk

4、: + e.mymethod();e.displayme();Systemoutprintln(*in try* _; /抛出异常e else if(argsO.charAt(O)= B throw new MyException (第一个字符不应是B! else System.out.println(args0); catch ( _ ) System.out.println(aaa.getMessage(); aaa.displayme(); + aaa.mymethod(); catch( _ ) 命令行参数个数错!程序填空:MyException super(msg)throw eMy

5、Exception aaaArrayIndexOutOfBoundsException5、阅读以下程序 import java.io.*;public class Test SubSubClass m=new SubSubClass(3,6,6); m.show();class SuperClass int a,b; SuperClass(int x,int y) a=x; b=y;class SubClass extends SuperClass int c; SubClass(int aa,int bb,int cc) super(aa,bb); c = cc;class SubSubCl

6、ass extends SubClass int a; SubSubClass(int aa,int bb,int cc) super(aa,bb,cc); a = aa + bb + cc; void show() System.out.println(a=+ a +nb=+ b +nc=+ c);请写出该程序的运行结果:a=60b=20c=306、阅读以下程序 String sl = Hello! String s2 = new String(World! System.out.println(sl.concat(s2);7、阅读以下程序public class Class1 public

7、 static void main(String args) int i,max,min; int a = 12,67,8,98,23,56,124,55,99,100); max= min= a0; for(i=1;a.length; i+) if( ai max) max = ai; System.out.println( max + + min); System.out.println();请写出该程序完成的功能:在数组中查找并输出最大值和最小值。8、阅读以下程序import java.awt.*;import java.applet.Applet;public class DrawMy

8、lmage extends Applet Image myImage; /定义一个图像类Image的对象myImage public void init() myImage= getImage(getDocumentBase(),pica.jpg public void paint(Graphics g) g.drawImage(myImage,0,0,this);在Applet界面中显示当前文件夹下名为“pica.jpg”的图像。9、阅读以下程序并填空。import java.applet.*;import .*;public class Mypicture _ Applet Image i

9、mage; public void _() try image=getlmage(new URL(getCodeBase(),image.gif); _(MalformedURLException e) g.drawlmage(image,0,0,_); public void start() _();程序填空题:extends init catch this repaint10、阅读以下程序:public class Sum public static void main( String args) double sum = 0.0 ; for ( int i = 1;= 100; i +

10、) sum += i;, System.out.println( sum= + sum );该程序完成的功能是:求sum=1+2+3+.+100的和。11、阅读以下程序: SuperClass(int x,int y) a=x; voidshow() System.out.println(+ a + + b);class SubClass extends SuperClass super(aa,bb); c=cc; voidshow() c=+ c +na=class SubSubClass extends SubClass int a; a=aa+bb+cc; void show()clas

11、s test SuperClass p=new SubSubClass(10,20,30); p.show();12、阅读以下程序:publiic class Test AB s = new AB(I love Java. System.out.println( s.toString() );class AB String sl; String s2; AB( String strl, String str2 ) sl = str1; s2 = str2; public String toString() return sl + s2;I love Java.13、阅读以下程序,并填空。imp

12、ort _class MyCopy public static void main(Stringo args) int ch; fin; _ fout; try fin = new (args0); fout = new (_); ch = fin.read(); while(ch!=-1) _ ch = fin.read(); fin.close(); fout.close(); catch (_ e1) System.out.println(使用格式错误!正确格式为:java mycopy源文件名目标文件名 System.exit(0); catch ( e3) 文件没有找到! catch

13、 (IOException e2) 流错误!args0fout.write(ch);14、阅读以下程序public class Reverse int a = new int10; for(i=0;n; i+) try BufferedReader br= new BufferedReader( new InputStreamReader(System.in); ai=Integer.parseInt(br.readLine(); /输入一个整数 catch (IOException e) ; for (i = n-1; i-)请写出此程序功能:程序运行时从键盘输入10个整数,然后倒序输出。1

14、5、阅读以下程序public class Test int i, s = 0; int a = 10, 20, 30, 40, 50, 60, 70, 80, 90; for ( i = 0 ; i a.length; if(ai % 3 = 0) s += ai;请写出此程序的输出结果:s=18016、阅读以下程序(提示:注意同步)class One synchronized void display(int num) two + num); Thread.sleep(1000); catch (InterruptedException e) System.out.println(”中断”)

15、; System.out.println(”完成”);class Two implements Runnable int number; One one; Thread t; public Two(One one_num, int n) one = one_num; number = n; t = new Thread(this); t.start(); public void run() one.display(number);public class Synch public static void main(String args) throws InterruptedException

16、 One one = new One(); int digit = 100; Two s1 = new Two(one,digit); Two s2 = new Two(one,digit); Two s3 = new Two(one,digit); Two s4 = new Two(one,digit); s1.t.join(); s2.t.join(); s3.t.join(); s4.t.join();Synch结束!此程序的输出结果是:two 100完成Synch 结束!17、阅读以下程序,并填空。import _ ;class _; fis = new_(args0); Buffer

17、edReader reader = new BufferedReader( ); String s; while(s=reader.readLine()!=_) System.out.println(+(i+)+: fis.close(); reader.close(); catch (IOException e) System.out.println(e); catch (_ e1) System.out.println(“缺少命令行参数!”);java.io.*;int i;fisnull18、阅读以下程序: double sum = 0.0: for (int i=1;=100; sum

18、 += i*i; System.out.println( +sum);该程序的功能是:求出sum的值为1到100的平方和。19、阅读以下程序:class Example public static void main(String args) int a = new int33; a00=1; a11=1; a22=1;数组a: for (int i=0; i+) for(int j=0; j ai.length; j+) System.out.print(aij + System.out.println();1 0 00 1 00 0 120、阅读以下程序:public class Test

19、2 static boolean foo(char c) System.out.print(c); return true; public static void main(String args) int i = 0: for(foo( foo() & (i2);C) i+; foo(DABDCBDCB21、阅读以下程序,并填空。import _;import java.awt.event.*;public class OvalDrawer extends Frame implements Runnable private Color colors= Color.RED,Color.BLACK,Color.BLUE, Color.GREEN,Color.DARK_GRAY ; private Color color; private int x=l0,y=10,width=10,height=10; public OvalDrawer(String title) super(title); _; /设置窗口大小为300*300 setVisible(true); _; /创建线程并启动 pub

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

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