下列叙述中,错误的是( )。
本题的功能是获得系统剪贴板中的内容。窗口中有一个菜单“Edit”和一个文本域,“Edit”中有菜单项“Cut”、“Copy”和“Paste”,在文本域中输入内容,可以通过菜单进行剪切、复制和粘贴操作,如果系统剪贴板为空,又做粘贴操作的话,则设置文本域中背景颜色为红色,并显示错误信息。
import Java.awt.*;
importjava.io.*;
import java.awt.datatransfer.*;
import java.awt.event.*;
class java3 extends Frame. implements ActionListener,
ClipboardOwner{
TextArea textArea=new TextArea;
java3{
super("java3");
addWindowListener(new WindowAdapter{
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
MenuBar mb=new MenuBar;
Menu m=new Menu("Edit");
setLayout(new BorderLayout);
add("Center",textArea);
m.add("Cut");
m.add("Copy");
m.add("Paste");
mb.add(m);
setMenuBar(this);
for(int i=0;i
m.itern(i).addActionListener(this);
}
setSize(300,300);
show;
}
public void actionPerformed(ActionEvent evt){
if("Paste".equals(evt.getActionCommand)){
boolean error=true;
Transferable t=
getToolkit.getSystemClipboard.getContents
(this);
try{
if(t! =nullt.isDataFlavorSupported(Dat-
aFlavor.stringFlavor)){
textArea.setBackground(Color.white);
textArea.setForeground(Color.black);
textArea.replaceRange(
(String)t.getTransferData(DataFlavor.stringFla-
vor),
textArea.getSelectionStart,
textArea.getSelectionEnd);
error=false;
}
}catch(UnsupportedFlavorException e){
}catch(IOException e){
}
if(error){
textArea.setBackground(Color.red);
textArea.setForeground(Color.white);
textArea.repaint;
textArea.setText("ERROR:\nEither the clip-
board"+"is empty or the contents is not fl string.");
}
}else if("Copy".equals(evt.getActionCommand
)) {
setContents;
}else if("Cut".equals(evt.getActionCommand
)){
setContents;
textArea.replaceRange("",textArea.getSelec-
tionStart,textArea.getSelectionEnd);
}
}
void setContents{
S=textArea.getSelectedText;
St ringSelection contents = new StringSelection
(s);
getToolkit.getSystemClipboard.setContents
(contents,this);
}
public void lostOwnership(Clipboard clipboard,
Transferable contents){
System.out.println("lost ownership");
}
public static void main(String args[]){
new java3;
}
}
本题随机产生若干字母(A~Z间),直到出现字母Q停止。
public ClaSS javal{
public static void main(String[]args){
;
do{
c=(char)( );
System.out.print(c+",");
}while( );
}
}
本题是一个Applet,页面中有两个文本域,当左侧文本域中的文本发生变化时,该文本域中的文本以行为单位按长度由短到长排列在右边的文本域中。
import java.util.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
Dublic class java2 extends Applet implements TextLis-
tener
{TextArea textl,text2;
public void init
{textl=new TextArea(6,15);
text9=new TextArea(6,15);
add(textl);add(text2);
text2.setEditable(false);
;
}
public void
{if(e.getSource= =textl)
{String s=textl.getText;
StringTokenizer fenxi=new StringTokenizer(s,"
,\n");
int n=fenxi.countTokens;
String a[]=new String[n];
for(int i=0;i<=n-1;i++)
{String temp=fenxi.nextToken;
a[i]=temp;
}
for(int i=0:i<=n-1;i++)
{for(int j=i+1;j<=n-1;j++)
{if(a[j].compareTo(a[i])<0)
{String t=a[j];a[j]=a[i];a[i]=t;
}
}
}
text2.setText(null);
for(int i=0;i
{text2.append(a[i]+"\n");
}
}
}
}
sum的值为0,则result=sum = =o?1:num/sum的值为( )。
下列叙述中正确的是( )。
关于下列代码编译或执行结果的描述中,正确的是( )。
public class Test{
public static void main(String argsE]){
TcstThread pml=new TestThread("One")
pml.start;
TestThread pm2=new TestThread("Tw0")
pm2.start;
}
}
class TestThread extends Thread(
private String sTname="";
TestThread(String s){
sTname=s;
}
public void run{
for(int i=O;i<2;i++){
try{
sleep(1000);
}catch(InterruptedException e){}
system.out.print(sTname+"");
}
}
}
阅读下列程序:
Public class Test implements Runnable{
Private int x=0l
Private int y=0;
boolean flag=true;
Public static void main(string[]args){
Test r=new Test;
Thead tl=new Thead(r);
Thead t2=new Thead(r);
tl.start;
t2.start;
}
Public void run{
While(flag){
x++;
y++;
system.out.println("("+x-","+y+")");
if(x>=10)
flag=false;
}
}
}
下列对程序运行结果描述的选项中,正确的是( )。
下列横线处应填写的语句是( )。
import JaVa.awt.*;
public class FirstFrame. extends Frame{
public static void main(String args[]){
FirstFrame. fr=new FirstFrame("First container!");
fr.setsize(240,240);
fr.setBackground(Color.yellow);
}
public FirstFrame(String str){
super(str);
}
}
结构化程序所要求的基本结构不包括( )。
下面描述中,不属于软件危机表现的是( )。
高级经济师考试试题精选练习(1)
高级经济师考试模拟练习题之单选题(1
高级经济师考试试题精选练习(2)
高级经济师考试试题精选练习(3)
高级经济师考试试题:经济法案例试题精
高级经济师考试模拟试题及答案
高级经济师考试试题及答案:单选练习题
高级经济师考试试题:经济法案例试题精
高级经济师考试模拟题及答案练习(1)
高级经济师考试模拟题及答案练习(2)