仅供参考,有错误请大家提出来,谢谢! 仅供参考,有错误请大家提出来,谢谢!
一、单选题: 1.A 2.B 3.D 4.B 5.C 6.A 7.D 8.B 9.B 10.B 11.B 12.B 13.D 14.C 15A 16.B 17.C 18.B 19.A 20.B 二、填空题 1.Applet 或是 Japplet 2.对象流 3. Math.sqrt(1-x*x)或是 Math.pow((1-x*x),0.5) 4. sleep()---------------------Thread.sleep()-----------大家看看那个比较准确 5. implements 6.2008 7. actionPerformed(ActionEvent e)--------- actionPerformed()------------大家看看那个比较准确 8. dos.close(); 9.(int)( 99*Math.random()) +1 注意 1.(int) (100*Math.random())不正确,2.表达式不以“; ”结束,3. 2、java.lang.Math 类的 静态方法:random()直接调用该静态方法,它返回一个大于等 0.0,小于 1.0 的 double 型的 伪随机数。 10.class 11.123 12.setLayout() 13.2 14. final 15. btn.setBackground(Color.green);
或 btn.setBackground(new Color(0,100,50));
16.java.net 17 类的静态方法…………本题不是很懂,懂的请共享一下哈 18.fld.setText(“ok”); 19.3 20.Application 程序 笔试试卷 三、编程题(每小题 10 分,共 20 分) 1、编写一个应用程序随机生成 100 个 500 以内的整数,统计其中大于 100 的个数要求输出 这些数及统计结果(10 分) -----------------------------------------------------------------------------------------------------------------------将我们的实验 1 改动一下即可 public class Rand { public static void main(String[] args) { int max=Integer.MIN_VALUE,min=Integer.MAX_VALUE;//赋初始值 int num, count=0;
for(int i=0;i<100;i++) { num= (int) (500*Math.random()); //0 到 499 的随机整数 if(num>max) max=num; if(num
100) {count++; System.out.print(num+"\t"); if((count)%10==0) System.out.println();//每十个数放在一行 } } System.out.println("\n\n 最大值为:"+max+"\t 最小值为:"+min); System.out.println("\n 大于 100 的个数为:"+count); } } ----------------------------------------------------------------------------------------------------------------答案: public class Rand { public static void main(String[] args) { int num,count=0; for(int i=0;i<100;i++) { num= (int) (500*Math.random()); //0 到 499 的随机整数 if(num>100) {count++; System.out.print(num+"\t"); if((count)%10==0) System.out.println();//每十个数放在一行 } } System.out.println("\n 大于 100 的个数为:"+count); } }
-------------------------------------------------------------------------------------------------------------
2、编写一个表示游泳卡的类 youyongCard,包括域“卡号”“”“余额” 、 、 ;并有相应的 set/get 方法(如 getName()返回,setBalance()设置卡中的余额) ,及消费 comsume 方法 (参数为本次消费额) ,并编写一个测试类 TestBook 进行测试,测试时先将卡中的余额设置 为 100 元,假设每次游泳费用 3 元,经过两次游泳消费后,最后输
出卡中的余额。 (10 分) 答案: //首先编写一个游泳卡类 class YouyongCard { private String CardNo; private String Name; private int Balance; public String getCardNo() { return CardNo; }
public void setCardNo(String cardNo) { CardNo = cardNo; }
public String getName() { return Name; }
public void setName(String name) { Name = name; }
public int getBalance() { return Balance;
} public void setBalance(int balance) { Balance = balance; } public void comsume(int balance) { this.Balance=this.Balance-balance; } } //再编一个测试类 public class TestCard { static int balance=3;//设置每次游泳费用