Swing构件从功能上位于顶层容器的包括:JFrame、JApplet、【 】和JWindow。
java.nio.channels包中的FileChannel类的作用是( )。
在面向对象方法学中,直接反映了用户对目标系统的要求的模型是【 】。
下列关于线程调度的叙述十,错误的是()。
以下程序是一个简单文本处理器,菜单项可以打开、编辑、保存一个文件。文件内容显示在下面的文本区域中(提示,打开文件通过文件选择器来完成)。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。运行结果如下图所示。注意:不改动程序的结构,不得增行或删行。importjava.awt.*;importjava.awt.event.*;importjava.io.*;importjavax.swing.*;classFileFrameextendsJFrame{Filefile;JTextPanetextpane;FileInputStreamreadStream;JScrollPanescroll;publicFileFrame(){super("文件浏览");JMenufileM=newJMenu("文件");OpenActionopen=newOpenAction();SaveActionclear=newSaveAction();ExitActionexit=newExitAction();JMenuBarmb=newJMenuBar();fileM.add(open);fileM.add(clear);fileM.add(exit);mb.add(fileM);textpane=newJTextPane();scroll=newJScrollPane(textpane);getContentPane().add(scroll);getContentPane().addJMenuBar(mb);}classOpenActionextendsAbstractAction{publicOpenAction(){super("打开");}publicvoidactionPerformed(ActionEvente){JFileChooserchooser=newJFileChooser();intstate=chooser.showOpenDialog(null);file=chooser.selectedFile();if(file!=nulltextpane.read(readStream,this);readStream.close();}catch(IOExceptionioE){}}}}classSaveActionextendsAbstractAction{publicSaveAction(){super("保存");}publicvoidactionPerformed(ActionEvente){if(file==null)return;try{FileWriterout=newFileWriter(file);out.read(textpane.getText());out.close();}catch(IOExceptionioE){}}}classExitActionextendsAbstractAction{publicExitAction(){super("退出");}publicvoidactionPerformed(ActionEvente){System.exit(0);}}publicstaticvoidmain(Stringargv[]){FileFramef=newFileFrame();f.setDefaultCloseOperation(JFrame.EXITONCLOSE);f.setSize(300,400);f.show();}}
请完善程序(程序文件名:Java_3.java)并进行调试。请在下画线处填入正确内容,然后删除下画线。请勿删除注释行和其他已有的语句内容。[题目要求]生成下面左边图形界面,单击图中的New按钮,弹出如右图所示的对话框。源程序:importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;publicclassJava_3{ publicstaticvoidmain(String[]args){ MulticastFrameframe=newMulticastFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.show(); }}classMulticastFrameextendsJFrame{ publicMulticastFrame(){ setTitle("MulticastTest"); setSize(WIDTH,HEIGHT); MulticastPanelpanel=newMulticastPanel(); ContainercontentPane=getContentPane(); contentPane.add((1)); } publicstaticfinalintWIDTH=300; publicstaticfinalintHEIGHT=200;}classMulticastPanelextendsJPanel} publicMulticastPanel(){ JButtonnewButton=newJButton("New"); add(newButton); ActionListenernewListener=newActionListener(){ publicvoidactionPerformed(ActionEventevent){ makeNewFrame(); } }; newButton.addActionListener(newListener); closeAllButton=newJButton("Closeall"); add(closeAllButton);}privatevoidmakeNewFrame(){ finalBlankFrameframe=newBlankFrame(); frame.show(); ActionListenercloseAllListener=newActionListener(){ publicvoidactionPerformed(ActionEventevent){ frame.(2)();//使窗口隐藏或消除 } }; closeAllButton.addActionListener((3)); } privateJButtoncloseAllButton;}ClassBlankFrameextendsJFrame{ publicBlankFrame(){ (4)++; setTitle("Frame"+counter); setSize(WIDTH,HEIGHT); setLocation(SPACING*counter,SPACING*counter); } publicstaticfinalintWIDTH=200; publicstaticfinalintHEIGHT=150; publicstaticfinalintSPACING=30; privatestaticintcounter=0;}
下列声明和赋值语句错误的是( )。
从对象流中读取对象,请在画线处加入代码完成此程序【 】。 import java.util.*; import java.io.*; public class UnSerializeDate { Date d = null; UnSerializeDate() { try{ FileInputStream f = new FileInputStream("data.ser"); ______; d = (Date) s.readObject(); f.close(); } catch(Exception e) { e.printStackTrace(); } } public static void main(String args[ ]) { UnSerializeDate a = new UnSerializeDate(); System.out.println("The date read is :"+a.d.toString()); } }
阅读下面程序 import java.io.*; public class ExceptionCatch { public static void main(String args[]) { try { FileInputStream fis=new FilelnputStream("text"); System.out.println("content of text is:"); } catch(FileNotFoundException e) { System.out.println(e); System.out.println("message:"+e.getMessage()); e.printStackTrace(System.out); } ______ { System.out.println(e); } } } 为保证程序正确运行,程序中下画线处的语句应是
用static修饰的方法,称为静态方法。它们不是对象的方法,而是整个类的方法。静态方法只能处理用关键字 ______ 修饰的数据。
在关系数据库中,用来组织索引结构联系的是( )。
一个项目具有—个项目主管,—个项目主管可管理多个项目,则实体“项目主管”与实体“项目”的联系属于【 】的联系。
按照流的方向来分,I/O流包括输入流和【 】。
下列程序段的输出结果是()。voiddoublearithmaticoperator(){inta=10,b=4,c=20,d=6;System.out.print(a+b*c+d);System.out.print(",");System.out.print(a+c%b);System.out.print(",");System.out.println(a++*b+c*-d);}
计算机系统的组成是( )。
显示图像使用的是Graphics类中的【 】方法。
在Java语言中有多种实现的机制,下列( )属于垃圾回收机制。
Java源程序文件编译后产生的文件成为字节码文件,其扩展名为【 】。
下列语句片段:int resultint a=17,b=6;result=(a%b>4)?a%b:a/b;System.out.println(result)的结果为 ( )
下列常见的系统定义的异常中,( )是输入、输出异常。