更多"下面是用户程序对Applet 类中方法paint ( )的重新定义,根"的相关试题:
[填空题]下面是用户程序对Applet类中方法paint( )的重新定义。根据程序功能,在指定的空白处填上适当的语句或语法成分。
public void paint (Graphics g)
g. ______ (“你好!”,10,20);
[填空题]下列程序实现的功能是当按下键盘时,在Applet中通过paint( )方法,在(50,50)位置处显示出按下的键的名称。在横线处填写正确的语句。
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Test7 extends Applet
String str="";
public void init( )
addKeyListener (new KeyAdapter( )
public void keyPressed(KeyEvent ke)
【16】 ;
repaint( );
);
requestFocus( );
public void paint(Graphics g)
g.drawString("你按下的键是:" +str, 50,50);
[单项选择]下面程序的功能是统计字符串中“array”的个数,在程序的空白处应填入的正确选项是
public class FindKeyWords
public static void main(String[]args)
String text="An array is a data structur that stores a collection of"
+"values of the same type. You access each indMdual value"
+"through an integer index. For example,if a is an array"
+"of inergers,then a[i]is the ith integer in the array.";
int arrayCount=0;
int index=-1;
String arrayStr="array";
index=text.indexOf(arrayStr);
while(index>=0)
++arrayCount;
index+=arrayStr.length( );
index=text.indexOf(arrayStr,index);
System.out.println("the text contains"+arrayCount+"arrays");
A. <
B. =
C. <=
D. >=
[填空题]在下面程序的空白处,填上适当的内容。
Import java.io. *:
import java.util. *;
class BufferTest
public static void main(String args[])throws IOExeeption
FileOutputStream unbuf=new FileoutputStream("test.one");
BufferedOutputStream bur=new ______ (new FileOutputStream("test.two"));
System.out.println("write file unbuffered:"+time(unbuf)+"ms");
System.out.println("write file buffered:"+time(buf)+"ms");
static int time(OutputStream os)throws IOException
Date then=new Date( );
for(int i=0;i<50000;i++)os.write(1);
os.close( );
return(int)((new Date( )).getTime( )-then.getTime( ));
[填空题]在程序的空白处填写适当的语句(一个空白处只能填写一条语句),使程序完成相应的数据处理。Form_Load事件过程给数组赋初值35,48,15,22,67。Form_Click事件过程对数组元素进行处理。
DimA rr(1 To 5)
Private Sub Form_Load( )
[11]
End Sub
Private Form_Click( )
[12]
If Int(x/3)=x/3 Then
PrintX
End If
Next X
End Sub
[单项选择]在下面程序的空白处,应填入的正确选项是
import java.io.*;
public class ObjectStreamTest
public static void main(String args[])throws IOExeeption
ObjectoutputStream oos=new ObjectOutputStream(new FileOutputStream("serial.bin"));
java.util.Date d=new java.util.Date( );
oos. ______(d);
ObjectInputStream ois=new ObjecttInputStream(new FileInputStream("serial.bin"));
try
java.util.Date restoredDate=(java.util.Date)ois.readObject( );
System.out.println("read object back from serial.bin file:"+restoredDate);
catch(classNotFoundException cnf)
System.out.println("class not found");
A. WriterObject
B. write
C. BufferedWriter
D. writerObject