计算机等级考试2级 Java-大题题库集_第1页
计算机等级考试2级 Java-大题题库集_第2页
计算机等级考试2级 Java-大题题库集_第3页
计算机等级考试2级 Java-大题题库集_第4页
计算机等级考试2级 Java-大题题库集_第5页
已阅读5页,还剩3页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、格式化DecimalFormat pre = new DecimalFormat(“”);JTextField output;output.setText(pre.format(result);Applet题1import java.applet.*import java.awt.Graphics;public class Java_1 extendsAppletpublic void paint(Graphics g)g.drawString(欢迎您,25,25);题2import java.awt.*;import jave.applet.*;public class Java_2 ext

2、endsAppletTextArea outputArea;public void init()setLayout(new BorderLayout();outputArea = new TextArea();add(outputArea);for(long i = 0; i 8002int a,x = 2008;while(x!=0)a = x % 10;x = x / 10;题2矩阵乘法public class Java_2 public static void main(String args) int a = 2, 3, 4, 4, 6, 5;int b = 1, 5, 2, 8, 5

3、, 9, 10, -3, 2, 7, -5, -18;/*Found*int c = new int24;for (int i = 0; i 2; i+) /*Found*for (int j = 0; j 4; j+) /*Found*cij = 0;for (int k = 0; k 3; k+)/*Found*cij += aik * bkj;System.out.print(cij + );System.out.println();题3import java.io.*;public class Java_1public static void main(String args) thr

4、ows ExceptionInputStreamReader ir = new InputSteamReader(System.in);BufferedReader in = new BufferedReader(ir);String s = in.readLine();int year = Integer.parseInt(s);if(year%4=0 & year%100!=0 | year%400=0)System.out.println(year+是闰年);elseSystem.out.println(year+不是闰年)题4自定义排序public class Java_2public

5、 static void main(String args)Student java = new Student3;java0 = new Student(李明, 80);java1 = new Student(赵冬, 75);java2 = new Student(王晓, 98);/*Found*Arrays.sort(java);System.out.println(Java成绩降序排序的结果是:);for (int i = 0; i java.length; i+)Student e = javai;/*Found*System.out.println(name= + e.getName

6、()+ ,fenshu= + e.getFenshu();/*Found*class Student implements Comparablepublic Student(String n, double f)name = n;fenshu = f;public String getName()return name;public double getFenshu()return fenshu;public int compareTo(Object otherObject)Student other = (Student)otherObject;if (fenshu other.fenshu) return -1;return 0;private String name;/*Found*private double fenshu;题5public class Java_1 public static void main(String args)int n;double e = 1.0;System.out.print(请输入n: );/*Found*Scanner scan = new Scanner (System.in);String nstr = scan.next();/*Found*n = Integ

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论