填空题请在下面代码中加入监听器语句。 import java.awt.*; import java.applet.Applet; public class Simple extends Apple implements MouseListener StringBuffer; public void init() //监听器语句 buffer=new StringBuffer(); addItem("initializing…"); public void moseEntered(MouseEvent event) public void moseExited(MouseEvent event) public void mosePressed(MouseEvent event) public void moseReleased(MouseEvent event) public void moseClicked(MouseEvent event) addltem("click!…");
填空题 【13】 类定义了Applet与其运行环境之间的一个标准接口。
填空题测试的目的是暴露错误,评价程序的可靠性;而{{U}} 【1】 {{/U}}的日的是发现错误的位置并改正错误。
填空题下列程序中,实例tat 是监听器,fr是事件源,fr上发生的事件委托tat进行处理。程序的执行结果是显示一个粉红色的窗口,单击关闭按钮,可关闭窗口。请将程序补充完整。
import java. awt.*;
import java. awt.event.*
public class Testppp
{
public static void main ( String args [])
{
Frame fr = new Frame ("The Adapter !" );
TheAdapterTest tat=new TheAdpterTest ( ):
fr. {{U}}【14】 {{/U}}
fr. setSize (200, 200):
fr. setBackground (Color. pink);
fr. setVisble (true):
}
}
class TheAdapterTest extends WindowAdapter
{
public voidWindowClosing (WindowEvent e)
{
System.exit ( 1);
}
}
填空题 【12】 方法能够反映正在加载图像的状态,如果加载还在进行、图像还在更新,则返回 true,否则返回false。
填空题JApplet是Swing的一种______容器。
填空题下面是顶层容器的一个程序,请在画线处填入适当的语句。
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
public class TopContenter{
public static void main(String args[]){
JFrame frame=new JFrame("TopContenter");
frame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
JLabel yellowLabel=new JLabel(" ");
yellowLabel.setOpaque(true);
yellowLabel.setBackground(Color.yellow);
yellowLabel.setPreferredSize(new Dimension(200,180));
JMenuBar cyanMenuBar=new JMenuBar();
cyanMenuBar.setOpaque(true);
cyanMenuBar.setBackground(Color.cyan);
cyanMenuBar.setPreferredSize(new Dimension(200,20));
______//设置菜单条
frame.getContentPane().add(yellowLabel,BorderLayout.CENTER);
frame.pack();
frame.setVisible(true);
}
}
填空题执行下面的赋值语句后,a的值为______。 a=Float.valueOf("12.34").floatValue();
填空题Java数字签名包括下列四个步骤:首先创建JAR文件,其次 【15】 ,然后对JAR文件进行数字签名,最后输出公钥证书。
填空题Java语言中如果要使用某个包中的类时,需要使用上{{U}} 【7】 {{/U}}导入。
填空题Java Applet 中的事件处理机制与Java Application相同,采用{{U}} 【14】 {{/U}}方式。
填空题短路逻辑运算符包括 【7】 和||。
填空题public class Test public static void main(String[ ] args) String name[ ]=new String[5]; for(int i=0; i<args. length; ++i) name[i] = args[i]; System. out. println(name[2]); 命令行中的输入为:java Test a b 程序的输出是 【11】 。
填空题下列是一个Java Applet程序,填空使它的功能为计算数组下标为偶数的各元素的和。 import java.applet.*; import java.awt.*; public class Testww extends Applet public void paint(Graphics g) int a[]=1,3,5,7,9,10; int total=0; float ave; for(int i=0;i〈a.length; 【9】 ) total+=a[i]; g.drawstring("Total of array elements:="+total,25,25);
填空题数组是有序数据的集合,数组中的每个元素具有相同的{{U}} {{U}} {{/U}} {{/U}}。
填空题下列是一个类的定义,将程序段补充完整。
class A {
String s;
【 】int a=66;
A(String sl) { s=sl;}
static int geta( ) { return a;}
}
填空题Applet类属______包。
填空题执行下面的程序段,输出结果为{{U}} 【7】 {{/U}}。
public class Q
{
public Static Void main(String args[])
{
int anar[]=new int[5];
System.out.println(anar[0]);
}
}
填空题在Java中,转义字符/n表示 【7】 。
填空题阅读下列代码 public class Test public static void main (String args[]) System.out.println(5/2); 其执行结果是 【7】 。
