二级java考试真题(2)
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
14
1.
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<anArray.length - 1 ){
System.out.print(anArray[i]);
System.out.print(',');
}
else{
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", new
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<anArray.length-1){
System.out.print(anArray[i]);
System.out.print('+');
}
else{
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);
}
}
class ExceptTestPanel extends Box
{
public ExceptTestPanel()
{
super(BoxLayout.Y_AXIS);
group = new ButtonGroup();
addRadioButton("整数被零除", new
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",
RMATION_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<intArray.length; 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("隶书", Font.BOLD, 24);
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<num; i++)
{
g.drawString("Hello!",25+i*50,25);
}
}
}
填"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等级考试!", MESSAGE_X, MESSAGE_Y);
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=789L;
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 {
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"
RMATION_MESSAGE);
24
1. import java.io.*;
public class Java_1
{
{
//*********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********。