JAVA期末考试试卷A答案
试卷
咸宁学院计算机科学与技术学院
2010年春季学期2009级计算机应用、软件工程
《面向对象程序设计》期末考试A卷答案
一、 填空(本题共15空,每空2分,共30分)
1.4,class 2.Float,Chararter,Boolean
3.final 4.新建、可执行、死亡、阻塞 5.Object 6.Universal Resource Locator。 7.Application、Applet 8.\
二、选择(本题共20小题,每题2分,共40分)
1.BBCBD ABCAC BDDDD BCACA
三、判断题(本题共5小题,每题2分,共10分)
下面的说法正确的打” √”,错误的打”X”
1.X √√√√
四、 编程题(本题共2小题,每题10分,共20分) 1.
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;//--------加1分
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;//--------加1分
public class ButtonTest implements ActionListener{//------加1分
JButton button1;
JButton button2;
public void initUI(){
JFrame jf = new JFrame();//-------按钮设置加2分
button1 = new JButton("不可见");
button2 = new JButton("不可用");
button1.addActionListener(this);
button2.addActionListener(this);
jf.setLayout(new FlowLayout());
jf.add(button1);
jf.add(button2);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.setSize(200, 200);
jf.setLocationRelativeTo(null);
jf.setVisible(true);
}
public void actionPerformed(ActionEvent e) { //----加3分
if(e.getActionCommand().equals("不可见")){
button1.setVisible(false);
}if(e.getActionCommand().equals("不可用")){
button2.setEnabled(false);
}
试卷
}
public static void main(String[] args) { //--------------加2分 ButtonTest bt = new ButtonTest();
bt.initUI();
}
}
2.
import java.util.Random;
public class QuickSort {
private int[] array = null;
public QuickSort(int length) {
Random random = new Random();
array = new int[length];
for(int i=0;i<length;i++) {
array[i] = getRanNum(random);
System.out.println("array["+i+"]="+array[i]);
}
this.array = array;
}
public int[] exeQuickSort() {
int leftIndex = 0;
int rightIndex = array.length - 1;
array = arithmetic(array, leftIndex, rightIndex);
return array;
}
private int getRanNum(Random random) {
int ranNum;
ranNum = random.nextInt(55);
if(ranNum == 0) {
ranNum = random.nextInt(55);
}
return ranNum;
}
private int[] arithmetic(int[] array, int leftIndex, int rightIndex) { int store;//-------变量设置加2分
int key;
int l = leftIndex;
int r = rightIndex;
key = array[leftIndex];
while(true) {
while(array[r] > key&&r > leftIndex) {//--------左找加2分 r--;
}
while(array[l] < key&&l < rightIndex) {//-------右找加2分 l++;
试卷
}
if(l <= r) {//-------交换加2分
store = array[r];
array[r] = array[l];
array[l] = store;
l++;
r--;
}
if(l > r) {
break;
}
}
if(r > leftIndex) {//--------左递归加1分 arithmetic(array, leftIndex, r);
}
if(l < rightIndex) {//--------右递归加1分 arithmetic(array, l, rightIndex);
}
return array;
}
public static void main(String[] args) { QuickSort qs = new QuickSort(10); int[] array = qs.exeQuickSort();
System.out.println("排序后的序列为:"); for(int i=0;i<array.length;i++) {
System.out.println("array["+i+"]="+array[i]); }
}
}
…… 此处隐藏:726字,全部文档内容请下载后查看。喜欢就下载吧 ……
相关推荐:
- [高等教育]一年级家长课程教案
- [高等教育]封丘县人民医院深入推进纠正医药购销领
- [高等教育]2017年6月大学英语四级真题试卷及答案(
- [高等教育]2017年北京第二外国语学院文学院824中
- [高等教育]7 高中历史第7单元1861年俄国农奴制改
- [高等教育]【K12学习】4、实际测量-苏教版六年级
- [高等教育]药具培训试卷题库及部分参考答案
- [高等教育]本土电子元器件目录分销商如何赢得生意
- [高等教育]七年级岭南版美术教案
- [高等教育]书作文之书法活动通讯稿
- [高等教育]Endnote X 软件使用入门和用法总结(LS)
- [高等教育]嵌入式系统的现状及发展状况
- [高等教育]2012抗菌药物专项整治活动方案解读
- [高等教育]人教版新课本一年级数学下册期末试卷
- [高等教育]爱课程民法学观后感
- [高等教育]930机组使用说明书1
- [高等教育]煤气设备设施点检标准
- [高等教育]常见室内观叶植物图解
- [高等教育]312党员群众路线心得体会
- [高等教育]小学信息(苗版)第一册全册教案
- 在市---局2010党建大会上的讲话
- 《科哲》提纲及补充阅读材料(2010.7)
- 苏州高博软件技术职业学院论文开题报告
- 兼职导游管理的困境及对策探讨
- 基于通用设计理念的现代厨房产品语义研
- 康乐一中2010年至2011年度鼓号队、花束
- 第10章_数据收集整理与描述_期末复习课
- 2008年黑龙江林甸商贸购物中心营销策划
- 水硬度的测定实验报告
- 五分钟教你拍摄夜景光绘照
- 2014年临床妇产科三基三严试题及答案
- 0第二课 纾解压力第一站了解压力
- 解析建筑工程电气设备安装施工技术要点
- 地方性应用型本科高校“双师型”师资队
- 高考语文专题复习课件:小说阅读指导
- 装饰工程投标书2
- 大学生就业难问题探讨及对策
- English and Its History
- 青岛市城市房屋修缮工程质量监督管理办
- 初中英语形容词和副词的用法和练习题




