public class Java_1{
public static void main(String[] args){
//*********Found******** String[] awt = new ______[3]; awt[0] = \"Abstract\"; awt[1] = \"Window\"; awt[2] = \"Tool kit\";
for (int i = 0; i < 3; i++)
//*********Found******** System.out.println(______); } }
1)String 2)填\"awt[i]\"
2.
public class Java_2 implements ActionListener{ Frame f; Button b; TextField tf;
public Java_2(){
f = new Frame(\"Show Date\");
//*********Found******** ______(new FlowLayout()); f.setSize(300,100);
//注册关闭窗口的
f.addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ System.exit(0); } });
b = new Button(\"显示当前日期\");
//*********Found******** ______(this);
tf = new TextField(30); f.add(b);
f.add(tf);
f.setVisible(true); }
public static void main(String[] args) { Java_2 t = new Java_2(); }
public void actionPerformed(ActionEvent e){ Date d = new Date(); //获取当前日期。 tf.setText(d.toString()); } }
填\"f.setLayout\",填\"b.addActionListener\"。 具体程序如下:
3.
import java.awt.*;
import java.awt.event.* ;
//*********Found********
public class Java_3 ______ ActionListener {
public static void main(String args[ ]) {
Java_3 tb = new Java_3();
Frame f = new Frame(\"Button Test\"); f.setSize(200,100);
f.setLayout(new FlowLayout(FlowLayout.CENTER));
Button b = new Button(\"Press the Button!\"); //*********Found******** b.______(tb);
f.add(b);
f.setVisible(true) ; }
public void actionPerformed(ActionEvent e) {
Frame fr = new Frame(\"An Other\"); fr.setBackground(Color.green);
fr.add(new Label(\"This frame shows when \"+\"pressing the button in Button Test\")); fr.pack();
fr.setVisible(true) ;
} }
填\"implements\填\"addActionListener\"。
15
1. import javax.swing.JOptionPane; public class Java_1{
public static void main( String args[] ) {
String output = \"\"; int count;
//*********Found********
for(count=1;count<=10; ______){ //*********Found******** if(count______)
break; // 当count为5时跳出循环 output += count + \" \"; }
output += \"\\nBroke out of loop at count = \" + count; JOptionPane.showMessageDialog( null, output ); System.exit( 0 ); } }
即\"count++\"或\"++count\填\">=5\"或\">4\"。
2. import java.io.*;
public class Java_2{
public static void main(String[] args) {
//*********Found********
int[] anArray=______; // 声明并创建包含10个元素的整型数组。 int i = 0; int total=0; try{
// 从data.dat中读出10个整数,放在整型数组中。
DataInputStream in = new DataInputStream(new FileInputStream(\"data.dat\")); while(in.available() != 0){ //*********Found******** anArray[i++]=in.______; }
in.close();
//将整型数组中的10个整数相加,并将这些数及其和显示输出。 System.out.print(\"Numbers: \");
for( i = 0; i < anArray.length; i++){             total = total+anArray[i];             if( i System.out.println(anArray[i]);             }          } System.out.println(\"Total:  \"+total);       }catch(IOException e1){}    } } 填\"new int[10]\"。填\"readInt()\"。 3. import java.awt.*; import java.awt.event.*; //*********Found******** import javax.______.*; import java.io.*; public class Java_3 { public static void main(String[] args)    { ExceptTestFrame frame = new ExceptTestFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);       frame.setVisible(true);    } } class ExceptTestFrame extends JFrame { public ExceptTestFrame()    { setTitle(\"ExceptTest\"); Container contentPane = getContentPane();       ExceptTestPanel panel = new ExceptTestPanel();       contentPane.add(panel);       pack();    } } class ExceptTestPanel extends Box { public ExceptTestPanel()    { super(BoxLayout.Y_AXIS);       group = new ButtonGroup(); addRadioButton(\"Integer divide by zero\         ActionListener()          { public void actionPerformed(ActionEvent event)             { a[1] = 1 / (a.length - a.length);             }          }); textField = new JTextField(30);      //*********Found********       add(______);    } private void addRadioButton(String s, ActionListener listener)    { JRadioButton button = new JRadioButton(s, false)          { protected void fireActionPerformed(ActionEvent event)             { try                { //*********Found******** textField.______(\"No exception\");                   super.fireActionPerformed(event);                } catch (Exception exception)                { textField.setText(exception.toString());                }             }          }; button.addActionListener(listener);       add(button); group.add(button);    } private ButtonGroup group;    private JTextField textField; private double[] a = new double[10]; } 填\"swing\"。填\"textField\"。填\"setText\"。 16 1. class Variable{     int x=0,y=0,z=0;     void init(int x,int y){ //*********Found********     ______=x;     this.y=y; int z=5;  //局部变量 System.out.println(\"*****在初始化中*****\"); System.out.println(\"x = \"+x+\"   y = \"+y+\"   z =\"+z);     } } public class Java_1{ public static void main (String[] args){      //*********Found********         Variable  v = new ______; System.out.println(\"*****在初始化之前*****\"); System.out.println(\"x = \"+v.x+\"   y = \"+v.y+\"   z =\"+v.z);         v.init(20,30); System.out.println(\"*****在初始化之后*****\"); System.out.println(\"x = \"+v.x+\"   y = \"+v.y+\"   z =\"+v.z);     } } 填\"this.x\",填\"Variable()\"。 2. import java.io.*; public class Java_2{ public static void main(String[] args) { int[] anArray  = new int[10];   // 声明并创建包含10个元素的整型数组。       int i = 0;        int total=0;               try{ // 从data.dat中读出10个整数,放在整型数组中。 //*********Found******** DataInputStream in=new DataInputStream(new ______(\"data.dat\"));          while(in.available() != 0){             anArray[i++] = in.readInt();          } in.close(); //将整型数组中的10个整数相加,并将这些数及其和显示输出。          for ( i = 0; i < anArray.length; i++){ //*********Found********             total=______; if (i System.out.print(anArray[i]);             } } System.out.println(\" =  \"+total);       }catch(IOException e1){}    } } 填\"FileInputStream\"。填\"total+anArray[i]\"或写成\"anArray[i]+total\"。 3. public class Java_3 { public static void main(String[] args)    { String num; if(args.length > 0) //*********Found********          num=______;       else num = \"5\"; //*********Found******** int input=Integer.parseInt(_____);       int result = Java_3(input); System.out.println(input+ \" 的阶乘是 \"+ result);    } public static int Java_3(int x)    { if( x < 0 )          return 0;       int fact = 1;       while(x > 1)       { //*********Found********          fact=______*x; x = x-1;       } return fact;    } } 填\"args[0]\"。填\"num\"。填\"fact\"。 17 1. import javax.swing.JOptionPane; public class Java_1 { public static void main( String args[] )   {       String output = \"\"; //*********Found******** for(int count=1;count<=10;______){      //*********Found********          if(count______) continue;  // 当count为5时跳过循环中的剩余代码             output += count + \" \";       } output += \"\\nUsed continue to skip printing 5\";       JOptionPane.showMessageDialog( null, output );       System.exit( 0 );    } } 即\"count++\"或\"++count\"。填\"==5\"。 2. import java.awt.*; import java.awt.event.*; import java.util.*; public class Java_2 implements ActionListener{    Frame f;    Button b;    TextField tf; //*********Found********    public ______(){ f = new Frame(\"Show Date\");       f.setLayout(new FlowLayout());       f.setSize(400,100); //注册窗口(WindowListener)      //*********Found********       ______(new WindowAdapter(){ public void windowClosing(WindowEvent e){             System.exit(0); }       }); b = new Button(\"显示当前日期\");       b.addActionListener(this);         tf = new TextField(30);          f.add(b);       f.add(tf); f.setVisible(true);    } public static void main(String[] args) {                Java_2 t = new Java_2();      } public void actionPerformed(ActionEvent e){       Date d = new Date();    //获取当前日期。       tf.setText(d.toString());     } } 填\"Java_2\";填\"f.addWindowListener\"。 3. import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; public class Java_3 { public static void main(String[] args)    { ExceptTestFrame frame = new ExceptTestFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);       frame.setVisible(true);    } } class ExceptTestFrame extends JFrame { public ExceptTestFrame()    { setTitle(\"ExceptTest\"); Container contentPane = getContentPane();       ExceptTestPanel panel = new ExceptTestPanel();       contentPane.add(panel); pack();    } } class ExceptTestPanel extends Box { public ExceptTestPanel()    { super(BoxLayout.Y_AXIS);       group = new ButtonGroup(); addRadioButton(\"整数被零除\         ActionListener()          { //*********Found******** public void ______(ActionEvent event)             { //*********Found******** a[1]=1/(a.length-a.______);             }          }); textField = new JTextField(30);       add(textField);    } private void addRadioButton(String s, ActionListener listener)    { JRadioButton button = new JRadioButton(s, false)          { protected void fireActionPerformed(ActionEvent event)             { try                { textField.setText(\"No exception\");                   super.fireActionPerformed(event);                } catch (Exception exception)                { //*********Found******** textField.______(exception.toString());                }             }          }; button.addActionListener(listener);       add(button); group.add(button);    } private ButtonGroup group;    private JTextField textField; private double[] a = new double[10]; } 填\"actionPerformed\"。 填\"length\",填\"setText\"。 18 1. import javax.swing.JOptionPane; public class Java_1 {    int x= 0; //*********Found********    String s = ______; public static void main( String args[] ){      //*********Found********       Java_1 d = new  ______;       String output; output = \"After instantiation:\\n\" + \"x : \"+d.x+\"  s : \"+d.s;       d.x = 77;                 d.s = \"Good bye\"; output += \"\\nAfter changing values:\\n\" +  \"x : \"+d.x+\"  s : \"+d.s;       JOptionPane.showMessageDialog( null, output,          \"Demonstrating Package Access\ JOptionPane.INFORMATION_MESSAGE );       System.exit( 0 );    } } 填字符串\"\"Hello\"\"。填\"Java_1()\"。 2. import java.io.*; public class Java_2 { public static void main(String[] args)     { int[] intArray = {1,2,3,4,5};         int j  ; try         { DataOutputStream out = new DataOutputStream(               new FileOutputStream(\"data.dat\"));             for(j =0; j //*********Found******** out.______(intArray[j]);             } out.close(); DataInputStream in = new DataInputStream(      //*********Found******** new ______(\"data.dat\"));             while(in.available() != 0)             { j = in.readInt(); System.out.println(j);             } in.close();         } catch(IOException e){}     } } 填\"writeInt\"。填\"FileInputStream\"。 3. import java.awt.*; import java.awt.font.*; import java.awt.geom.*; import javax.swing.*; public class Java_3 { public static void main(String[] args)    { FontFrame frame = new FontFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);       frame.setVisible(true);    } } //*********Found******** class FontFrame ______ JFrame { public FontFrame()    { setTitle(\"沁园春.雪\"); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);       FontPanel panel = new FontPanel(); Container contentPane = getContentPane(); contentPane.add(panel);    } public static final int DEFAULT_WIDTH = 300;    public static final int DEFAULT_HEIGHT = 200; } //*********Found******** class FontPanel extends ______ { public void paintComponent(Graphics g)    { super.paintComponent(g); Graphics2D g2 = (Graphics2D)g; String message = \"数风流人物,还看今朝!\";       Font f = new Font(\"隶书\      g2.setFont(f); FontRenderContext context = g2.getFontRenderContext();       Rectangle2D bounds = f.getStringBounds(message, context);       double x = (getWidth() - bounds.getWidth()) / 2;       double y = (getHeight() - bounds.getHeight()) / 2;       double ascent = -bounds.getY();       double baseY = y + ascent;       g2.setPaint(Color.RED);      //*********Found******** g2.draw______(message, (int)x, (int)(baseY));    } } 填\"extends\"。填\"JPanel\"。填\"String\"。 19 1. import java.io.*; public class Java_1 { public static void main(String args[])     { //*********Found********         ____   a='h';         byte   b=6;         int    i=200;         long   n=567L; //*********Found********         _____  f=98.99f;         double d=4.7788;         int    aa=a+i; long   nn=n-aa;         float  ff=b*f; double dd=ff/aa+d; System.out.println(\"aa=\"+aa);         System.out.println(\"nn=\"+nn);         System.out.println(\"ff=\"+ff);         System.out.println(\"dd=\"+dd);     } } 填\"char\"或\"byte\"或\"short\"或\"int\"。填\"float\"。 2.     //*********Found******** public class Java_2 extends ______ { public static void main(String args[ ])     { Java_2 t = new Java_2();      //*********Found********         t.______;     } public void run( )     { int i = 0;         while( true )         { System.out.println(\"你好! \");             if (i++==4)  break ;         } System.out.println();     } } 填\"Thread\"。填\"start()\"。 3. import java.awt.*; import java.awt.event.*; import java.util.*; import javax.swing.*; import javax.swing.Timer; public class Java_3 { public static void main(String[] args)     { //*********Found******** ActionListener listener = new ______(); Timer t = new Timer(1000, listener);         t.start(); JOptionPane.showMessageDialog(null, \"Quit program?\");         System.exit(0);     } } //*********Found******** class TimePrinter ______ ActionListener { public void actionPerformed(ActionEvent event)     { Date now = new Date(); System.out.println(\"At the tone, the time is \" + now);         Toolkit.getDefaultToolkit().beep();     } } 填\"TimePrinter\"。填\"implements\"。 20 1. import java.io.*; public class Java_1 { public static void main(String args[])     { char   a='h';         byte   b1=6; //*********Found********         ______ i=200; //*********Found********         ______ b=567L;         float  f=98.99f;         double d=4.7788;         int    aa=a+i;         long   bb=b-aa;         float  ff=b1*f; double dd=ff/aa+d; System.out.println(\"aa=\"+aa);         System.out.println(\"bb=\"+bb);         System.out.println(\"ff=\"+ff);         System.out.println(\"dd=\"+dd);     } } 填\"short\"或\"int\"。填\"long\"。 2. import java.awt.* ; import java.applet.* ; //*********Found******** public class Java_2 ______ { int num; public void init()     { //*********Found******** String s = getParameter(______);  //从html文件中获取参数         num = Integer.parseInt(s);     } public void paint(Graphics g)     { for( int i=0; i 填\"extends  Applet\"或\"extends javax.swing.JApplet\"。填\"\"num\"\"。 3. import javax.swing.*; import java.awt.*; public class Java_3 { public static void main(String[] args)     { WelcomFrame frame = new WelcomFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);      //*********Found********         frame.setVisible(______);     } } //*********Found******** class WelcomFrame ______ JFrame { public WelcomFrame()     { setTitle(\"Java等级考试\"); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);         WelcomPanel panel = new WelcomPanel();         Container contentPane = getContentPane();         contentPane.add(panel);     } public static final int DEFAULT_WIDTH = 250;     public static final int DEFAULT_HEIGHT = 100; } //*********Found******** class WelcomPanel extends ______        { public void paintComponent(Graphics g)     { super.paintComponent(g); g.drawString(\"欢迎参加Java等级考试!\        setBackground(Color.white);     } public static final int MESSAGE_X = 60;     public static final int MESSAGE_Y = 50; } 填\"true\"。填\"extends\"。填\"JPanel\"。 21 1. import java.io.*; public class Java_1 { public static void main(String args[])     { char   a='p';         byte   b1=6;         int    i=400;         long   b=345L;         float  f=98.99f;         double d=4.7788; //*********Found********         ______ aa=a+i;         long   bb=b-aa; //*********Found********         ______ ff=b1*f; double dd=ff/aa+d; System.out.println(\"aa=\"+aa);         System.out.println(\"bb=\"+bb); System.out.println(\"ff=\"+ff);         System.out.println(\"dd=\"+dd);     } } 填\"int\"或\"long\"。填\"float\"。 2. import java.awt.*; import javax.swing.*; //*********Found******** public class Java_2 extends ______ { public void init()     { Container contentPane = getContentPane(); JLabel label = new JLabel(\"Java的诞生是对传统计算模式的挑战!\             SwingConstants.CENTER);         contentPane.add(label);     } } 填\"JApplet\"。填\"Java_2.class\";填\"HEIGHT\"。 3. import java.awt.*; import javax.swing.*; public class Java_3 extends JApplet { //*********Found********    public void _____()    { Container contentPane = getContentPane();      //*********Found********       JLabel label = new ______ (\"Java是一个跨平台的面向网络的计算机语言。\         SwingConstants.CENTER);      //*********Found********       contentPane.add(_____);    } } 填\"init\"或\"start\"。填\"JLabel\",填\"label\"。 22 1. import java.io.*; public class Java_1 { public static void main(String args[]) { char   a='x';         byte   b1=6;         int    i=100;         long   b=7L;         float  f=98.99f;         double d=4.7788;         int    aa=a+i; //*********Found********         ______ bb=b-aa;         float  ff=b1*f; //*********Found********         ______ dd=ff/aa+d; System.out.println(\"aa=\"+aa);         System.out.println(\"bb=\"+bb);         System.out.println(\"ff=\"+ff);         System.out.println(\"dd=\"+dd);     } } 填\"long\"。填\"double\"。 2. import java.awt.*; import java.awt.event.*; import java.util.*; public class Java_2 implements ActionListener{    Frame f;    Button b;    TextField tf; public Java_2(){ f = new Frame(\"Show Words\");       f.setLayout(new FlowLayout());       f.setSize(400,100); //注册关闭窗口的 f.addWindowListener(new WindowAdapter(){          public void windowClosing(WindowEvent e){             System.exit(0);          }       }); b = new Button(\"显示字符串\"); //*********Found******** ______(this);   //给按钮注册       f.add(b); tf = new TextField(30); //*********Found******** ______(tf);  //将文本框添加到窗口中       f.setVisible(true);    } public static void main(String[] args) {                Java_2 t = new Java_2();      } public void actionPerformed(ActionEvent e){       tf.setText(\"祝你成功!\");     } } 填\"b.addActionListener\"。填\"f.add\"。 3. //打印无符号整数位 import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Java_3 extends JFrame {    public Java_3(){ super( \"打印无符号整数位\" );       Container c = getContentPane();       c.setLayout( new FlowLayout() ); c.add( new JLabel( \"请输入整数: \" ) ); final JTextField output = new JTextField( 33 );       JTextField input = new JTextField( 10 );       input.addActionListener(          new ActionListener() { public void actionPerformed( ActionEvent e ){                int val = Integer.parseInt(                   e.getActionCommand() );                output.setText( getBits( val ) );             }          }       ); c.add( input ); c.add( new JLabel( \"该数的二进制位表示是\" ) );             output.setEditable( false ); //*********Found********       c.add( __output____ ); setSize( 720, 70 );       show();    } private String getBits( int value ){       int displayMask = 1 << 31; StringBuffer buf = new StringBuffer( 35 );       for ( int c = 1; c <= 32; c++ ) {          buf.append( ( value & displayMask ) == 0 ? '0' : '1' );          value <<= 1;          if ( c % 8 == 0 ) buf.append( ' ' );       } return buf.toString();    } public static void main( String args[] ){       Java_3 app = new Java_3();       app.addWindowListener(          new WindowAdapter() {      //*********Found******** public void windowClosing( _WindowEvent__ e ){                System.exit( 0 );             }          }       );    } } 23 1. import java.io.*; public class Java_1 { public static void main(String args[])     { //*********Found********         ______ a='w';         byte   b1=6;         int    i=500;         long   b=123L; float  f=98.99f;         double d=4.7788;      //*********Found********         ______ aa=a+i;         long   bb=b-aa;         float  ff=b1*f;         double dd=ff/aa+d; System.out.println(\"aa=\"+aa);         System.out.println(\"bb=\"+bb);         System.out.println(\"ff=\"+ff);         System.out.println(\"dd=\"+dd);     } } 填\"byte\"或\"short\"或\"char\"或\"int\"或\"long\"。填\"int\"或\"long\"。 2. public class Java_2 { public static void main(String[] args) {      //*********Found******** int[][] aMatrix = new ______[]; int i = 0;       int j = 0;       int k = 0; //*********Found********       for ( i = 0; i < ______; i++) { aMatrix[i]=new int[j+1];  //创建数组。 //给每个数组元素赋值并在一行中打印输出。          for ( k = 0; k < aMatrix[i].length; k++) {             aMatrix[i][k]=k+1; System.out.print(aMatrix[i][k] + \" \");          }          j++; System.out.println(); //换行。        }    } } 填\"int[6][]\"。填\"aMatrix.length\"。 3. //if语句实例 import javax.swing.JOptionPane; public class Java_3 { public static void main( String args[] ){ String firstNumber,   //存储第1个输入数据              secondNumber,  //存储第2个输入数据              result;        //字符串输出 int number1,          //用来比较的第1个int型数据            number2;          //用来比较的第2个int型数据       //以字符串格式读输入数据       firstNumber = JOptionPane.showInputDialog( \"请输入第1个整数:\" );       secondNumber = JOptionPane.showInputDialog( \"请输入第2个整数:\" );                 //将字符串转换为int整数      //*********Found******** number1 = Integer.parseInt( __________ );       number2 = Integer.parseInt( secondNumber );       //用空字符串初始化结果变量       result = \"\"; if ( number1 == number2 ) result = number1 + \" == \" + number2;       if ( number1 != number2 ) result = number1 + \" != \" + number2;       if ( number1 < number2 ) result = result + \"\\n\" + number1 + \" < \" + number2;       if ( number1 > number2 ) result = result + \"\\n\" + number1 + \" > \" + number2;       if ( number1 <= number2 ) result = result + \"\\n\" + number1 + \" <= \" + number2;       if ( number1 >= number2 ) result = result + \"\\n\" + number1 + \" >= \" + number2;       //显示结果 JOptionPane.showMessageDialog(          null, result, \"比较结果\     //*********Found********          JOptionPane.__________ );       System.exit( 0 );    } } 填入\"firstNumber\" JOptionPane.INFORMATION_MESSAGE); 24 1. import java.io.*; public class Java_1 { public static void main(String args[])     { //*********Found******** ______ double TQ_IN=8.88;  //定义常量 byte   b;         int    i; //*********Found********         ______ c; double d=2.79994; b=011;         i=234;         c='q'; System.out.println(\"TQ_IN= \"+TQ_IN);         System.out.println(\"b= \"+b);         System.out.println(\"i= \"+i);         System.out.println(\"c= \"+c);         System.out.println(\"d= \"+d);     } } 填\"final\"。填\"char\"。 2. import java.awt.*; import java.awt.event.*; //*********Found******** public class Java_2 extends Frame __ implements ______ ActionListener{    public static void main(String args[ ]){       Java_2 fr = new Java_2(\"Test\");       fr.setSize(200,200); fr.setLayout(new GridLayout(2,1)); Button b = new Button(\"退出\");      //*********Found******** b.addActionListener(new __Java_2______());       fr.add(b); fr.setVisible(true);    } public void actionPerformed( ActionEvent e){       System.exit(0); } public Java_2(String str){       super(str);    } public Java_2( ){      } } 3. import java.awt.*; import java.awt.event.*; //*********Found******** public class Java_3 implements ActionListener,__ WindowListener ____ { Frame f; Button be,bw,bs,bn,bc;     public void create()     { f=new Frame(\"Exit test\");         be=new Button(\"East\");         bw=new Button(\"West\");         bs=new Button(\"South\");         bn=new Button(\"North\");         bc=new Button(\"Exit\");         f.add(be,\"East\");         f.add(bw,\"West\");         f.add(bs,\"South\");         f.add(bn,\"North\");         f.add(bc,\"Center\"); bc.addActionListener(this);//为按钮注册         f.addWindowListener(this);         f.setSize(200,200);         f.setVisible(true);     } public static void main(String args[])     { //*********Found******** Java_3 fa=___ Java_3() _______;         fa.create();     } public void actionPerformed(ActionEvent e)     { //*********Found******** ___ System.exit _______(0);    //实现窗口关闭功能     } public void windowOpened(WindowEvent e){}      public void windowClosing(WindowEvent e)     { //*********Found******** ____ System.exit _______(0);    //实现窗口关闭功能     } public void windowClosed(WindowEvent e){}     public void windowIconified(WindowEvent e){}     public void windowDeiconified(WindowEvent e){}     public void windowActivated(WindowEvent e){}     public void windowDeactivated(WindowEvent e){} } 25 1. import java.io.*; public class Java_1 { //*********Found******** public static ______ main(String args[])     { final  double TQ_IN=188.88; long   b;         int    i; //*********Found********         ______ c; double d=2.79994; b=0456;         i=1024;         c='U'; System.out.println(\"TQ_IN= \"+TQ_IN);         System.out.println(\"b= \"+b);         System.out.println(\"i= \"+i);         System.out.println(\"c= \"+c); System.out.println(\"d= \"+d);     } } 填\"void\"。填\"char\"。 2. public class Java_2 { public static void main(String[] args) {       int[][] aTriangle = new int[6][];       int i = 0;       int j = 6;       int k = 0; for ( i = 0; i < aTriangle.length; i++) { aTriangle[i]=new int[j];  //创建数组。 //给每个数组元素赋值并在一行中打印输出。      //*********Found********          for ( k = 0; k < ______; k++) {             aTriangle[i][k]=k+1;      //*********Found******** System.out.print(______ + \" \");          }          j--; System.out.println(); //换行。       }    } } 填\"aTriangle[i].length\"。填\"aTriangle[i][k]\"。 3. //程序的功能是从1开始,每秒打印一个递增的整数。 import java.awt.*; import java.awt.event.*; import java.util.*; import javax.swing.*; import javax.swing.Timer; public class Java_3{ public static void main(String[] args){ ActionListener listener = new TimePrinter();      //*********Found******** Timer t = new Timer(1000, __ ActionListener ________);       t.start(); JOptionPane.showMessageDialog(null, \"退出程序?\");       System.exit(0);    } } //*********Found******** class TimePrinter implements __________{      //*********Found******** public void action____ actionPerformed ______(ActionEvent event){       i++; System.out.println(i); Toolkit.getDefaultToolkit().beep();    } int i = 0; } 26 1. //使用标记的break语句 import javax.swing.JOptionPane; public class Java_1 { public static void main( String args[] ){       String output = \"\";       //标注复合语句       stop: { for ( int row = 1; row <= 10; row++ ) { for ( int column = 1; column <= 5 ; column++ ) {                if ( row == 5 )      //*********Found******** break __ stop ____;                output += \"*  \";             } output += \"\\n\";          } //跳过下一行 output += \"\\n循环正常终止\";       } JOptionPane.showMessageDialog(      //*********Found******** null, output,\"__ 用标记的break语句测试成功!____\         JOptionPane.INFORMATION_MESSAGE );       System.exit( 0 );    } } 2. import java.awt.*; import java.awt.event.*; //*********Found******** public class Java_2 ________ Frame implements ActionListener{    public static void main(String args[]){       Java_2 fr = new Java_2(\"Hello !\"); fr.setLayout( new FlowLayout());       fr.setSize(200,100); fr.setBackground(Color.blue);       Button b = new Button(\"确定\");      //*********Found********       b.________(new Java_2());       fr.add(b); fr.setVisible(true);    } public void actionPerformed( ActionEvent e){       System.exit(0);    } public Java_2(String str){       super(str);    } public Java_2( ){    } } 填\"extends\"。填addActionListener 。 3. import java.text.*; public class Java_3{ public static void main(String[] args){ Person p = new Student(\"王甜甜\计算机科学\"); System.out.println(p.getName() + \   } } abstract class Person{ public Person(String n){       name = n;    } //*********Found******** public _abstract_____ String getDescription();    public String getName(){       return name;    } private String name; } //*********Found******** class Student __ extends ____ Person{    public Student(String n, String m){       super(n);       major = m;    } //*********Found******** public String _getDescription_____(){       return \"学生专业是:\" + major;    } private String major; } 27 1. //用目标标记的Continue语句实例 import javax.swing.JOptionPane; public class Java_1 { public static void main( String args[] ){       String output = \"\"; nextRow: for ( int row = 1; row <= 5; row++ ) {             output += \"\\n\"; for ( int column = 1; column <= 10; column++ ) {                  if ( column > row )      //*********Found******** continue __nextRow________;                   output += \"*  \";             }          } JOptionPane.showMessageDialog(      //*********Found******** null, output,\"__ Testing continue with a label ________\         JOptionPane.INFORMATION_MESSAGE );       System.exit( 0 );    } } 2. import java.awt.*; import java.awt.event.*; public class Java_2 extends Frame implements WindowListener {      //*********Found********    public _ Java_2_____() { setLayout(new FlowLayout());       add(new Button(\"Button 1\"));       add(new Button(\"2\")); add(new Button(\"Button 3\"));      //*********Found********       addWindowListener(this); } public static void main(String args[]) {       Java_2 window = new Java_2();       window.setTitle(\"AWT Test\");       window.pack();       window.show();    } public void windowClosing(WindowEvent e) {       System.exit(0);    } public void windowClosed(WindowEvent e) { }    public void windowOpened(WindowEvent e) { }    public void windowIconified(WindowEvent e) { }    public void windowDeiconified(WindowEvent e) { }    public void windowActivated(WindowEvent e) { }    public void windowDeactivated(WindowEvent e) { } } 3. //程序的功能是求以命令行参数指定的整数的阶乘。 public class Java_3{ public static void main(String[] args){       String num; if(args.length > 0) //*********Found********          num = __________;       else num = \"5\"; //*********Found******** int input = Integer.parseInt(__________);       double result = factorial(input); System.out.println(input+ \" 的阶乘是 \"+ result);    } public static double factorial(int x){       if( x < 0 )       return 0.0; double fact = 1.0;       while(x > 1){ //*********Found********          fact __________ *x;          x = x-1;       } return fact;    } } 填\"args[0]\"。 填\"num\"。填\"=fact\"。              
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- huatuo0.cn 版权所有 湘ICP备2023017654号-2
违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务