Java语言程序设计2021年1月21日每日一练
单选题下列整型常量中表示的是十六进制的整数
进入题库练习
填空题下列程序中,实例tat是监听器,fr是事件源,fr上发生的事件委托tat进行处理。程序的执行结果是显示一个粉红色的窗口,单击关闭按钮,可关闭窗口。请填完整程序。  import java.awt.*;  importjava.awt.event.*;  public class Testppp     public static void main(String args[ ])       Frame fr=new Frame("The Adapter!”);    TheAdapterTest tat=new TheAdapterTest( );    fr  【15】      fr.setSize(200,200);    fr.setBackground(Color.pink);    fr.setVisible(true);       class TheAdapterTest extends WindowAdapter     public void windowClosing(WindowEvent e)        System.exit(1);   
进入题库练习
填空题下列程序段的输出结果为 【10】 。 public class Test void printValue(int m) do Systern.out,println("The value is "+m); while(-m>10); public static void main(String arg[]) int i=10; Test t=new Test(); t.print Value(i);
进入题库练习
单选题下列描述中不正确的一项是______。 A.import语句告诉Java用户需要哪个包(package)中的类 B.所有的类必须实例化才能调用它的数据成员和方法 C.System类不可能实例化,它的所有方法都是通过类变量来调用的 D.package语句用于将源文件存入所指定的包中
进入题库练习
单选题若所用变量都已正确定义,则在以下选项中,非法的表达式是 ( ) A) a!=4||b==1 B) 'a'%3 C) 'a'=1/2 D) 'a'+32
进入题库练习
问答题本程序的功能是读取选中的文件。窗口中有“打开文件”和“关闭”两个按钮,单击“打开文件”按钮,则弹出“Openfile”对话框,选中其中一个文件,单击“打开”按钮后返回主窗口,同时选中的文件字符流就显示在文本域中。单击“关闭”按钮退出程序,如图所示。importjava.awt.*;importjava.awt.event.*;importjava.io.*;publicclassexam_98extendsFrameimplementsWindowAdapter{Stringdirectory;TextAreatextarea;publicexam_98(){this(null,null);}publicexam_98(Stringfilename){this(null,filename);}publicexam_98(Stringdirectory,Stringfilename){super();addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){dispose();}});textarea=newTextArea("",24,80);textarea.setFont(newFont("MonoSpaced",Font.PLAIN,12));textarea.setEditable(false);this.add("Center",textarea);Panelp=newPanel();p.setLayout(newFlowLayout(FlowLayout.RIGHT,10,5));this.add(p,"South");Fontfont=newFont("SansSerif",Font.BOLD,14);Buttonopenfile=newButton("打开文件");Buttonclose=newButton("关闭");openfile.addActionListener(this);openfile.setCommand("open");openfile.setFont(font);close,addActionListener(this);close.setActionCommand("close");close.setFont(font);p.add(openfile);p.add(close);this.pack();if(directory==null){Filef;if((filename!=null)filename=f.getName();}elsedirectory=System.getProperty("user.dir");}this.directory=directory;setfile(directory,filename);}publicvoidsetFile(Stringdirectory,Stringfilename){if((filename==null)||(filename.length()==0))return;Filef;FileReaderin=null;try{f=newFile(directory,filename);in=newFileReader(f);char[]buffer=newchar[4096];intlen;textarea.setText("");while((len=in.read(buffer))!=-1){Strings=newString(buffer,0,len);textarea.append(s);}this.setTitle("exam_98:"+filename);textarea.setCaretPosition(0);}catch(IOExceptione){textarea.setText(e.getClass().getName()+":"+e.getMessage());this.setTitle("exam_98:"+filename+":I/OException");}finally{try{if(in!=null)in.close();}catch(IOExceptione){}}}publicvoidactionPerformed(ActionEvente){Stringcmd=e.getActionCommand();if(cmd.equals("open")){FileDialogf=newFileDialog(this,"OpenFile",FileDialog.LOAD);f.setDirectory(directory);f.show();directory=f.getDirectory();setFile(directory,f.getFile());f.dispose();}elseif(cmd.equals("close"))this.dispose();}staticpublicvoidmain(String[]args)throwsIOException{Framef=newexam_98((args.length==1)?args[0]:null);f.addWindowListener(newWindowAdapter(){publicvoidwindowClosed(WindowEvente){System.exit(0);}});f.show();}}
进入题库练习
单选题下列方法中,不属于WindowListener接口的是 A. windowOpened() B. windowClosed() C. windowAetivated() D. mouseDragged()
进入题库练习
单选题下列( )是面向大型企业级用容器管理专用构件的应用平台。
进入题库练习
填空题字符变量以char类型表示,它在内存中占______位bit。
进入题库练习
单选题设有以下函数: void fun(int n,char*s)…… 则下面对函数指针的定义和赋值均正确的是( )。 A.void (*pf)(); pf=fun; B.void *pf(); pf=fun; C.void*pf();*pf=fun; D.void(*pf)(int,char);pf=&fun;
进入题库练习