程序填空题 1、定义一个长度为 5 的字符串数组,并初始化其初值为“open”, “door”, “the”, “open”, “name”;计算该数组中 “open”出现的次数,并倒序输出数组元素。 public class Test{ public void static main(String[] args){ //声明并初始化数组 (1) int count = 0; //计算该数组中 “open”出现的次数 (2) { (3) count++; } //倒序输出数组元素 (4) { (5) } } } 2、定义一个抽象类 AbstractTest,其中有一个公共的抽象方法 printMsg()。然后定义此抽象类的一个子类 DefaultTest,包括的成员变量有姓名,学号,分数,且此类中包括二个构造方法。 abstract class AbstractTest{ (1) } (2) { String name; String id; int score; //接收三个参数的构造方法 (3) //接收姓名和学号二个参数的构造方法 (4) //实现抽象方法,方法体为打印出学生的姓名与成绩 (5) } 3、编写程序实现窗口,包含一个标签、一个文本框和一个按钮,当用户单击按钮时,程序把文本框中的内容提制到标签中。(使用 AWT) //引入相关包 (1) public MyFrame{ public MyFrame(){ Frame fr = new Frame(); //设置窗体的布局为FlowLayout (2) Label lbl = new Label(“Init info”); TextField txt = new TextField(30); Button btn = new Button(“Sure”); fr.add(lbl); fr.add(txt); fr.add(btn); //给按钮注册监听器 (3) //使用窗体可见,并设置大小 (4) } //定义内部类监听ActionEvent 事件 (5) { public void actionPerformed(ActionEvent e){ lbl.setText(txt.getText()); } } public static void main(String[] args){ new MyFrame(); } } 4、设计程序实现带菜单的窗口,包含 “File” 和 “Edit”二个菜单,在 “File”下又包含 “New”, “Open”, “Exit”三个菜单项,选择 “Exit”项时退出应用程序。(提示:涉及到的类有 MenuBar, Menu, MenuItem) import java.awt.*; import java.awt.event.*; public class MenuTest{ //定义各菜单项 MenuItem newItem = new MenuItem(“New”); MenuItem openItem = new MenuItem(“Open”); MenuItem exitItem = new MenuItem(“Exit”); public MenuTest(){ Frame fr = new Frame(); //定义菜单 Menu fileMenu = new Menu(“File”); M...