欢迎来到天天文库
浏览记录
ID:5721533
大小:23.90 KB
页数:16页
时间:2017-12-23
《第三届全国itat信息技术大赛j复赛试题》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、第三届全国ITAT教育工程就业技能大赛复赛试题Java程序设计(A卷)答案1.packageprogramming;publicclassArray{publicdoublegetMax(double[]a){doublemax=a[0];for(inti=1;i2、blicstaticvoidmain(String[]args){doublea[]={9.8,12,45,67,23,1.98,2.55,45};ArrayA=newArray();System.out.println(A.getMax(a));System.out.println(A.getMin(a));}}2.packageprogramming;importjava.io.*;publicclassReadFile{publicstaticvoidmain(String[]args){Strings;try{//1、通过使用FileInputStre3、am类实现FileInputStreamin=newFileInputStream("D:\Java\javaCompetition\src\programming\ReadFile.java");byte[]b=newbyte[in.available()];while(in.read(b)!=-1)System.out.println(newString(b));in.close();//2、通过使用BufferedReader类实现/*BufferedReaderbr=newBufferedReader(newInputStreamReader4、(newFileInputStream("D:\Java\javaCompetition\src\programming\ReadFile.java")));while((s=br.readLine())!=null)System.out.println(s);*/}catch(FileNotFoundExceptionfe){fe.printStackTrace();}catch(IOExceptionie){ie.printStackTrace();}}}3.packageprogramming;importjava.io.*;publiccla5、ssRandomAccess{publicstaticvoidmain(String[]args){try{RandomAccessFileraf=newRandomAccessFile("tom.dat","rw");raf.setLength(0);for(inti=1;i<=10;i++)raf.writeInt(i);System.out.println("文件长度(注意,以字节为单位):"+raf.length());for(inti=9;i>=0;i--){raf.seek(i*4);System.out.print(raf.readInt()+"6、");}System.out.print("");raf.seek(0);//文件指针移动至文件开头System.out.println("第一个数字:"+raf.readInt());raf.seek(raf.length());//文件指针移动至文件末尾raf.writeInt(90);//在文件末尾添加一个新的int值raf.seek(40);//文件指针移动至最后一个int值处System.out.println("最后一个数字:"+raf.readInt());raf.close();}catch(FileNotFoundExceptionfe)7、{fe.printStackTrace();}catch(IOExceptione){e.printStackTrace();}}}4.packageprogramming;importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;publicclassGuiMultiThreadextendsJFrame{publicGuiMultiThread(){MultiThreadPanelmtp=newMultiThreadPanel();this.add(mtp);this.setSize(500,18、000);this.setVisibl
2、blicstaticvoidmain(String[]args){doublea[]={9.8,12,45,67,23,1.98,2.55,45};ArrayA=newArray();System.out.println(A.getMax(a));System.out.println(A.getMin(a));}}2.packageprogramming;importjava.io.*;publicclassReadFile{publicstaticvoidmain(String[]args){Strings;try{//1、通过使用FileInputStre
3、am类实现FileInputStreamin=newFileInputStream("D:\Java\javaCompetition\src\programming\ReadFile.java");byte[]b=newbyte[in.available()];while(in.read(b)!=-1)System.out.println(newString(b));in.close();//2、通过使用BufferedReader类实现/*BufferedReaderbr=newBufferedReader(newInputStreamReader
4、(newFileInputStream("D:\Java\javaCompetition\src\programming\ReadFile.java")));while((s=br.readLine())!=null)System.out.println(s);*/}catch(FileNotFoundExceptionfe){fe.printStackTrace();}catch(IOExceptionie){ie.printStackTrace();}}}3.packageprogramming;importjava.io.*;publiccla
5、ssRandomAccess{publicstaticvoidmain(String[]args){try{RandomAccessFileraf=newRandomAccessFile("tom.dat","rw");raf.setLength(0);for(inti=1;i<=10;i++)raf.writeInt(i);System.out.println("文件长度(注意,以字节为单位):"+raf.length());for(inti=9;i>=0;i--){raf.seek(i*4);System.out.print(raf.readInt()+"
6、");}System.out.print("");raf.seek(0);//文件指针移动至文件开头System.out.println("第一个数字:"+raf.readInt());raf.seek(raf.length());//文件指针移动至文件末尾raf.writeInt(90);//在文件末尾添加一个新的int值raf.seek(40);//文件指针移动至最后一个int值处System.out.println("最后一个数字:"+raf.readInt());raf.close();}catch(FileNotFoundExceptionfe)
7、{fe.printStackTrace();}catch(IOExceptione){e.printStackTrace();}}}4.packageprogramming;importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;publicclassGuiMultiThreadextendsJFrame{publicGuiMultiThread(){MultiThreadPanelmtp=newMultiThreadPanel();this.add(mtp);this.setSize(500,1
8、000);this.setVisibl
此文档下载收益归作者所有