网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

请完成下列Java程序。程序的执行结果是生成一个具有一个按钮的窗体,并且按钮的标签是“欢迎参加全国计算机等级考试—Java部分!”字样。

注意:请勿改动main()主方法和其他已有的语句内容,仅在下划线处填入适当的语句。

import java.awt.*;

import java.awt.event.*;

public class TestActionEvent

{

public static void main(String args[])

{

Frame. f=new Frame("Test");

Button b=new Button("欢迎参加Java考试!");

TestListener testmonitor=new TestListener();

Monitor bh=new Monitor();

b.addActionListener(bh);

f.addwindowListener(testmonitor);

f.add(b);

f.setSize(150,100);

f.setVisible(true);

}

}

class Monitor ___________ ActionListener

{

public void actionPerformed(ActionEvent e)

{

System.out.println("a button has been pressed");

}

}

class TestListener__________WindowAdapter

{

public void windowClosing(WindowEvent e)

{

System.exit(1);

}

}


参考答案

更多 “ 请完成下列Java程序。程序的执行结果是生成一个具有一个按钮的窗体,并且按钮的标签是“欢迎参加全国计算机等级考试—Java部分!”字样。注意:请勿改动main()主方法和其他已有的语句内容,仅在下划线处填入适当的语句。import java.awt.*;import java.awt.event.*;public class TestActionEvent{public static void main(String args[]){Frame. f=new Frame("Test");Button b=new Button("欢迎参加Java考试!");TestListener testmonitor=new TestListener();Monitor bh=new Monitor();b.addActionListener(bh);f.addwindowListener(testmonitor);f.add(b);f.setSize(150,100);f.setVisible(true);}}class Monitor ___________ ActionListener{public void actionPerformed(ActionEvent e){System.out.println("a button has been pressed");}}class TestListener__________WindowAdapter{public void windowClosing(WindowEvent e){System.exit(1);}} ” 相关考题
考题 请完成下列Java程序。程序的功能是利用迭代法求一个数的平方根(求平方根的迭代公式为:Xn+1=1/2(Xn+a/Xn)).注意:请勿改动main()主方法和其他已有的语句内容,仅在下划线处填入适当的语句。public class PingFangGen{public static void main(String args[]){System. out. println(Math, sqrt(2.0));}static double sqrt(______){double x=1.0do{_______}while( Math. abs(x*x-a)/a>le-6)return x;}}

考题 接口是抽象方法和常量的集合,是一种特殊的抽象类。下面的程序是对接口的操作,请在程序的每条横线处填写一个语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。______________MyInterface{public static int NUM=100;public abstract void print();}public class ClassName___________MyInterface{public void print(){System.out.println(NUM);}public static void main(String args[]){__________________________obj .print();}}

考题 下面程序执行后,输出结果为:true请在程序的每条横线处填写一个语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。public class TestStringCompare{{public static void main(String ____________________ args){char charl[]={'t','e','s','t'};char char2[]={'t','e','s','t','1'};String str1=new String(___________________);String str2=new String(char2,0,4);System.out.println(__________________________);}}

考题 下面的程序的功能是简单的进行键盘输入测试,请在程序的每条横线处填写一个语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。____________________public class TestKeyBoardInPut{public static void main(String[] args){String yourname=JOptionPane. ____________________ ("What is your name?");System.out.println("Hello"+yourname);____________________.exit(0);}}

考题 请完成下列Java程序。实例listener是监听器,frm是事件源,fr上发生的事件委托tat进行处理。程序的执行结果是显示一个蓝色的窗口,单击关闭按钮,可关闭窗口。注意:请勿改动main()主方法和其他已有的语句内容,仅在下划线处填入适当的语句。源程序文件代码清单如下:import java.awt.*;import java.awt.event.*;public class BlueWindow{public static void main(String args[]){Frame. frm=new Frame. ("欢迎参加Java考试!");TheAdapterTest listener=new TheAdapterTest();frm. ______;frm.setSize(200,200);frm.setBackground(Color.blue);frm. ______;}}class TheAdapterTest extends WindowAdapter{public void windowClosing(WindowEvent e){System.exit(1);}}

考题 下面的程序是用do_while语句计算10的阶乘。请在程序的每条横线处填写一个语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。源程序文件代码清单如下:public class DoWhileLoop{public static void main(________){int n=10;long result=1;do{_______________}______________System.out.println("10的阶乘为: "+result);}}

考题 请完成下列Java程序:实现打印出自己的源文件的功能。注意:请勿改动main()主方法和其他已有语句内容,仅在下划线处填入适当的语句。import java.io.*;import java.util.StringTokenizer;public class ex27_2{public static void main(String args[])throws IOException{FileInputStream fis=new FileInputStream("ex27_2.java");DataInputStream dis=new DataInputStream(fis);String str=null;while(true){__________________;if(str==null){__________________;}StringTokenizer st=new StringTokenizer(str);while(st.hasMoreTokens()){System.out.print(st.nextToken()+ " " );}System.out.println();}}}

考题 请完成下列Java程序。程序的输出结果:a=6,b=5。注意:请勿改动main()主方法和其他已有语句内容,仅在下划线处填入适当的语句。程序运行结果如下:public class ex38_2{public static void main(String args[]){int a=5,b=6;a=_________;b=a-b;a=_________;System.out.println("a="+a+"\tb="+b);}}

考题 阅读以下说明和Java代码,将解答写入对应栏内。【说明】请完成下列Java程序。程序的执行结果是生成一个具有一个TextField类型的对象in、 Button类型的对象btn和Label类型的对象out图形用户界面,程序的功能是计算用户输入数的平方,如图3所示。注意:请勿改动main()主方法和其他已有的语句内容,仅在下划线处填入适当的语句。【程序】import java. awt.*;import java, awt. event.*;public class square {public static void main(String args[ ]){(1)}}class AppFrame. extends Frame{TheAdapterTest listener = new TheAdapterTest( );Text Field in = new TextField (5);Button btn = new Button("计算");Label ut = new Label("用于显示计算结果");public AppFrame( ){setLayout( new FlowLayout( ));add(in);add(btn)add(out);btn. addActionListener( new BtnActionAdapter( ));addWindowListener (listener);setSize(400,100);show( );}class BtnActionAdapter implements (2) {public void actionPerformed((3)) {String s = in. getText( );double d =(4)double sq = d * d;out. setText(d+"的平方是:" +sq);}}class TheAdapterTest extends WindowAdapter{public void windowCIosing((5)){System. exit(1)}}}