Super sup=new Super();
System.out.println(sup.x); //( )
System.out.println(sup.n); //( )
System.out.println(sup.method1()); //( ) System.out.println(sup.method2()); //( ) } }
class Super{ int x=1 , y=2 ; static int n=50; int method1(){ return (x>y)?x:y; }
static int method2(){ return n--; } }
class Sub extends Super{ int method1() {
return (x static int method2(){ return n++;//static用的父类的 } } 3. 写出以下程序的运行结果。(每空2分,共4分) class First { First() { System.out.println (\); } } public class Second extends First { Second() { System.out.println(\); } 第 6 页 共 14 页 public static void main(String[] args) { Second mine= new Second(); } } 运行结果: ( ) ( ) 得分 评阅人 三、补程序 (13分) 图形用户界面程序填空。界面效果:姓名、学 号两个标签之后两个文本行。在文本行填入姓名和学号后,单击按钮“提交”,学号从上往下掉,姓名从左往右移动。注意有的空需将不完整的Java 保留字补齐 (每空1分) import java.applet.___; //(1) import java.awt.*; import java.awt._____.ActionEvent; //(2) public class NameDrop extends Applet implements Runnable,____ { //(3) private int x=0; private int y=0; private _____ t; //(4) private boolean b=false; private Button button; private TextField textFieldName; private TextField textFieldID; private String name; private String ID; private Label LabelName; private Label LabelID; public void ___(){ //(5) this.setSize(300,300); button=new Button(\提交 \); textFieldName=new TextField(10); 第 7 页 共 14 页 textFieldID=new TextField(10); button.add____________(this); //(6) LabelName=new Label(\姓名\); LabelID=new Label(\学号\); this.add(button); this.add(LabelName); this.add(textFieldName); this.add(LabelID); this.add(textFieldID); } public void start(){ if(t==null){ t=new Thread(_________); t.start(); } } public void stop(){ if(t!=null){ t.interrupt(); t=null; } } public void paint(Graphics ___){ if(b){ x=x+1; y=y+1; g.drawString(name,x,80); g.drawString(ID,50,y); } } public void run() { while(t!=null){______(); try{ 第 8 页 共 14 页 //(7) //(8) //(9) t._______(20); //(10) }______catch(InterruptedException break; e){ //(11) } } } public void actionPerformed(ActionEvent e) { } if(e.________()==button){ //(12) b=true; name=textFieldName.getText(); ID=textFieldID._________(); //(13) } 得分 评阅人 四 编程题(20分) 学生(Student)评奖方法(Award)有多种,比如: 励志奖(award1)、优秀学生干部(award2)等;学生类别也有多种,比如:有一本(Student1)、三本(Strudent3)等。要求编写学生评奖系统,评奖方法可以扩展,学生身份可以扩展。(7个类或接口,最后Test类2分,其他每个类或接口3分) 输出: 学生 张三 采用: 打分方法 1 学生 张三 采用: 打分方法 2 学生 李四 采用: 打分方法 1 学生 李四 采用: 打分方法 2 第 9 页 共 14 页 河南大学2012-2013学年第一学期期末考试 Java程序设计 试卷A卷 参考答案与评分标准 (卷面总分:100分) 一、单项选择题(每小题2分,共20小题,总计40分) B C D B A C B A A C A A D C C C A B C C 二、读程序,给结果(共27分) 1、 90 2、 1,50,1,50,1,51,1,51,1,50,2,50 3、 10,20 三、补程序 (13分) (1)Applet (2)event (3)ActionListener (4)Thread (5)init() (6)ActionListener (7)this (8) g (9)start() (10)sleep() (11)catch (12)getSource (13)getText() 四、编程题(20分) public interface Award { } public class Award1 implements Award{ } public class Award2 implements Award{ public void score(){ System.out.println(\打分方法 2\); } 第 10 页 共 14 页 public abstract void score(); public void score(){ System.out.println(\打分方法 1\); }