计算机类
公务员类
工程类
语言类
金融会计类
计算机类
医学类
研究生类
专业技术资格
职业技能资格
学历类
党建思政类
计算机等级考试(NCRE)
全国计算机应用水平考试(NIT)
计算机软件水平考试
计算机等级考试(NCRE)
全国高校计算机等级考试CCT
行业认证
信息素养
计算机等级考试二级
计算机等级考试一级
网络工程师(计算机等级考试四级)
计算机等级考试二级
数据库工程师(计算机等级考试四级)
计算机等级考试三级
信息安全工程师(计算机等级考试四级)
嵌入式系统开发工程师(计算机等级考试四级)
软件测试工程师(计算机等级考试四级)
Java语言程序设计
Python语言程序设计
WPS Office高级应用与设计
C语言程序设计
C++语言程序设计
Java语言程序设计
Visual Basic语言程序设计
Web程序设计
Access数据库程序设计
MySQL数据库程序设计
Visual FoxPro数据库程序设计
办公软件高级应用
问答题本程序的功能是对列表中的项进行添加和删除操作。窗口中有“添加哲学家”、“删除选中的哲学家”两个按钮和一个列表,单击“添加哲学家”按钮,则弹出一个对话框,输入姓名后单击“确定”按钮返回主窗口,同时在列表框中的最后添加了一个新的列表项,单击“删除选中的哲学家”按钮后,将删除选中的列表项。列表项不支持多项选择,如图所示。importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;publicclassexam_68extendsJFrame{privateDefaultListModelphilosophers;privateJListlist;publicexam_68(){super("exam_68");philosophers=newDefaultListModel();philosophers.addElement("苏格拉底");philosophers.addElement("博拉图");philosophers.addElement("亚里斯多德");philosophers.addElement("托马斯");philosophers.addElement("以马利");philosophers.addElement("尼采");list=newJList();list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);JButtonaddButton=newJButton("添加哲学家");addButton.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEventevent){Stringname=JOptionPane.showInputDialog(exam_68,"输入姓名");philosophers.addElement(name);}});JButtonremoveButton=newJButton("删除选中的哲学家");removeButton.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEventevent){philosophers.removeElement(list.getSelectedItem());}});JPanelinputPanel=newJPanel();inputPanel.add(addButton);inputPanel.add(removeButton);Containercontainer=getContentPane();container.add(list,BorderLayout.CENTER);container.add(inputPanel,BorderLayout.NORTH);setDefaultCloseOperation(EXIT_ON_CLOSE);setSize(400,300);setVisible(true);}publicstaticvoidmain(Stringargs[]){newexam_68();}}
进入题库练习
问答题下面是一个Applet程序,其功能是显示有闪烁特效的从左向右的滚动文字。要求定义6种颜色:RED,GREEN,ORANGE,GRAY,YELLOW,BLUE,让文字在滚动过程中根据文字的位置循环选定—种颜色,并快速切换,达到一边移动一边闪烁的效果,同时要求通过htm1文件传递所显示的文字和延迟时间的参数,Applet程序能够根据参数实现显示功能。请改正程序中的错误(有下划线的语句),使程序能输山正确的结果。注意:不改动程序的结构,不得增行或删行。程序运行结果如下:importjava.applet.Applet;importjava.awt.*;/*<appletcode="ex12_3.class"width=800height=400><paramname=textvalue="WelcometoNCRExamination!"><paramname=delayvalue="50"></applet>*/publicclassex12_3extendsAppletimplementsRunnable{privateStringstrText;privateThreadthMover=null;privateintnX,nY,nDelay;privateFontfFont;privateintgetParameter(Strings1,ints2){Strings=getParameter(s1);return(s!=null)?IntegerparseInt(s):s2;}privateStringgetParameter(Strings1,Strings2){Strings=getParameter(s1);{{U}}return(s!=null)?Integer.parseInt(s):s2;{{/U}}}publicvoidinit(){fFont=newFont("TimesRome",Font.BOLD,40);setBackground(Color.black);strText=getParameter("text","PutyourmessageinstrTextparm");{{U}}nX=getSize().height;{{/U}}nY=80;nDelay=getParameter("delay",80);}publicvoidstart(){if(thMover==null){thMover=newThread(this);thMover.start();}}publicvoidstop(){thMover=null;}publicvoidrun(){while(thMover!=null){try{Thread.sleep(nDelay);}catch(InterruptedExceptione){}repaint();}}publicvoidpaint(Graphicsg){switch(nX%6){case0:g.setColor(Color.RED);break;case1:g.setColor(Color.GREEN)break;case2:g.setColor(Color.ORANGE;break;case3:g.setColor(Color.GRAY);break;case4:g.setColor(Color.YELLOW;break;case5:g.setColor(Color.BLUE);}g.setFont(fFont);g.drawString(strText,nX,nY);if({{U}}nX<=0{{/U}})nX=getSize().width;}}{{B}}ex123.htm1{{/B}}<HTML><HEAD><TITLE>ex12_3</TITLE></HEAD><BODY><appletcode="exl2_3.class"width=800height=400><paramname=textvalue="WelcometoNCRExamination!"><paramname=delayvalue="50"></applet></BODY></HTML>
进入题库练习
问答题请完成下列Java程序。程序的功能是复制文件并显示文件,将每个字符读入,并写入另一个文件,同时显示出来(注意:在本题中,当前目录下的README.txt文件打印在屏幕上,并写入另一个文件temp.txt中)。 注意:请勿改动main()主方法和其他已有的语句内容,仅在下画线处填人适当的语句。 import java.io.*; public class FileCopyBy{ public static void main(String args[]){ try{ FileReader input=new FileReader("README.txt"); FileWriter output=new FileWriter("temp.txt"); int c=input.read(); while(__________) { __________ System.out.print((char)c); c=input.read(); } input.close(); output.close(); } catch(IOException e) { System.out.println(e); } } }
进入题库练习
问答题请完成下列Java程序。程序的功能是利用迭代法求一个数的平方根(求平方根的迭代公式为: Xn+1=1/2(Xn+a/Xn))。 注意:请勿改动main()主方法和其他已有的语句内容,仅在下划线处填入适当的语句。 源程序代码文件清单如下: public class PingFangGen public static void main(String args[ ]) System.out.println(Math.sqrt(2.0)); static double sqrt(______) double x=1.0; do ______; while(Math.abs(x*x-a)/a>1e-6); return x;
进入题库练习
问答题本程序的功能是监听对于下拉菜单的操作。窗口中有三个按钮:“Remove”、“RemoveAll”、“Insert”和一个下拉菜单,下拉菜单中有10个菜单项,选中某个菜单项后,单击“Remove”按钮,则删除该菜单项,如果单击“Insert”按钮,则在菜单项的最下方添加一个新的菜单项,如果单击“RemoveAll”按钮,则同时删除所有菜单项,如图所示。importjava.awt.*;importjava.awt.event.*;classexam_51extendsFrameimplementsActionListener{Choicechoice=newChoice();ButtonremoveBtn=newButton("Remove");ButtonremoveAllBtn=newButton("RemoveAll");ButtonaddBtn=newButton("Insert");intlastItemCount=0;exam_51(){super("exam_51");for(inti=0;i<10;i++){choice.add("item"+(lastItemCount++));}addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){System.exit(0);}});removeBtn.addActionListener(this);addBtn.addActionListener(this);removeAllBtn.addActionListener(this);Panelp=newPanel(newGridLayout(1,0));p.add(removeBtn);p.add(removeAllBtn);p.add(addBtn);add(choice,BorderLayout.CENTER);add(p,BorderLayout.NORTH);setSize(300,150);show();}publicvoidactionPerformed(ActionEvente){Stringcmd=e.getActionCommand();if(cmd.equals("RemoveAll")){choice.remove("ALL");}else{inttarget=choice.getSelectedIndex();if(cmd.equals("Remove")){if(target>=0){choice.removeItem(target);}}else{if(target>=0){choice.insert("item"+(lastItemCount++),target);choice.select(target);}else{choice.add("item"+(lastItemCount++));}}}removeBtn.setEnabled(choice.getItemCount()>0);removeAllBtn.setEnabled(choice.getItemCount()>0);}staticpublicvoidmain(String[]args){newexam_51();}}
进入题库练习
问答题下面的程序是打印输出100~300之间的不能被3整除的数。请在每条横线处填写一条语句,使程序的功能完整。 注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。 public class printNo3and5 void print() int n ; for(n=100 ;n if(n%3==0) __________ System.out.println(n); public static__________main(String args[]) printNo3and5 obj=new printN03and5(); __________
进入题库练习
问答题本题的功能是用冒泡法对数组元素arr[]=30,1,-9,70进行从小到大排列。冒泡法排序是比较相邻的两个元素的大小,然后把小的元素交换到前而。 public class java1 public static void main(String[]args) int i,j; int arr[]=30,1,-9,70); int n=______; for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) if(arr[i]>arr[j]) int temp=arr[i]; ______; ______; for(i=0;i<n;i++) System.out.print(arr[i]+"");
进入题库练习
问答题System. out. println ( "团队测试不通过");
进入题库练习
问答题注意:下面出现的“考生文件夹”均为%USER%。在考生文件夹中存有文件名为Java_2.java文件,本题功能是在1~n之间的自然数中,每次抽取k个数字来抽奖,计算中奖几率的算法为n*(n-1)*(n-2)*…*(n-k+1)/1*2*3*…*k请完善Java_2.java文件,并进行调试,使程序先显示输入窗口如下:然后从自然数1~20中,每次抽3个数,计算中奖几率,并将最终结果在命令行中显示,其形式类似:你中奖的几率是1/1140.Goodluck!由于Java_2.java文件不完整,请在注释行“//*********Found*********”下一行语句的下画线地方填入正确内容,然后删除下画线,请勿删除注释行或其他已有语句内容。存盘时,文件必须存放在考生文件夹下,不得改变原有文件的文件名。给定源程序:importJavax.swing.*;publicclassJava_2publicstaticvoidmain(String[]args)//*********Found**********Stringinput=______.showInputDialog("你想抽几位数?");//*********Found**********intk=Integer.parseInt(______);input=JOptionPane.showInputDialog("你想在自然数中抽的最高数是几?:);//*********Found**********intn=______.parseInt(input);intlotteryOdds=1;for(inti=1;i<=k;i++)lotteryOdds=lotteryOdds*(n-i+1)/i;//*********Found**********System.outprintln("你中奖的几率是1/"+______+".Goodluck!");System.exit(0);
进入题库练习
问答题下面的程序是10000以内的“相亲数”。所谓相亲数是指这样的一对数:甲数的约数之和等于乙数,而乙数的约数等于甲数,(例如220和284是一对相亲数)请在程序的每条横线处填写一条语句,使程序的功能完整。 注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。 public class QinShu{ public static void main(String args[ ]){ for(int n=1;n<9999;n++){ int s=divsum(n); if({{U}} {{/U}}) System.out.println(n+","+s); } } public static int divsum(int n){//该方法的功能是求一个数的所有约数 int s=0; for(int i=1;____________________i++) if(____________________)s+=i; return s; } }
进入题库练习
问答题本程序的功能是定义了自己的组件类。窗口中叠放着几个组件,当鼠标置于某个组件上时,该组件的边框和标签开始有频率的闪动,如图所示。importjava.awt.*;importjava.awt.event.*;classexam_80extendsFrame{exam_80(){super("exam_80");addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){System.exit(0);}});addNotify();Insetsinsets=getInsets();for(inti=0;i<4;i++){FakeButtonfb=newFakeButton("PushMe");add(fb,0);fb.setBounds(insets.left+i*20,insets.top+i*20,100,100);}setLayout(null);setSize(300,300);show();}publicvoidpaint(Graphicsg){Update();}Imagebbuf;GraphicsbbufG;publicvoidupdate(Graphicsg){FontMetricsfm=g.getFontMetrics();intw=getSize().width;inth=getSize().height;if(bbuf==null||bbuf.getWidth(null)<w||bbuf.getHeight(null)<h){bbuf=createImage(w,h);bbufG=bbuf.getGraphics();}bbufG.setClip(0,0,w,h);super.paint(bbufG);g.drawImage(bbuf,0,0,this);}publicstaticvoidmain(String[]args){newexam_80();}}classFakeButtonextendsComponentimplementsThread{Stringlabel;booleanblink=false;booleanblinkOn;FakeButton(Stringl){label=l;addMouseListener(newMouseEventHandler());(newThread(this)).start();}publicvoidpaint(Graphicsg){FontMetricsfm=g.getFontMetrics();intw=getSize().width;inth=getSize().height;g.setColor(Color.black);g.fillRect(0,0,w,h);if(blink}else{g.setColor(Color.white);}g.drawString(label,(w-fm.stringWidth(label))/2,(h-fm.getHeight())/2+fm.getAscent());g.drawRect(0,0,w-1,h-1);}classMouseEventHandlerextendsMouseAdapter{publicvoidmouseEntered(MouseEventevt){blink=true;repaint();}publicvoidmouseExited(MouseEventevt){blink=false;repaint();}}publicvoidrun(){while(true){try{blinkOn=!blinkOn;if(blink){repaint();}this.sleep(250);}catch(Exceptione){}}}}
进入题库练习
问答题下面是一个Applet程序,其功能是建立一个图形用户界面的窗口,包括一个文本显示区和一个按钮,点击按钮,可以声文本区已有的文本基础上追加显示10条"Welcome to China!”信息,并且文本区由滚动条控制文本的上下滚动。请改正程序中的错误(有下画线的语句),使程序能输出正确的结果。 注意:不改动程序的结构,不得增行或删行。 import javax.swing.*; import java.awt.*; import java.awt.event.*; /* 〈applet code="exl3_4.class"width=800 height=400〉 〈/applet〉 */ public class exl4_3 extends JApplet JButton jb=new JButton("Add Text"); JTextPane jtp=new JTextPane(); public void init() jb.addActionListener(new Ac60nListener() pubhc void actionPerformed(ActionEvent e) for(int i=1;i jtp.geText(jtp.setText()+"Welcome to China! /n"); ); Container cp=getContentPane(); cp.add(new JScrollPane(jtp)); cp.add(BorderLayout.SOUTH,jtp); public static void main(Stdng[] args) ex14_3 obj14_3=new ex14_3(); String str=obj14_3.getClass().toString(); if(str.indexOf("class")!=-1) str=str.substring(6); JFrame frm=new JFrame(str); frm.addWindowListener(new WindowAdapter() pubhc void windowClosing(WindowEvent we) System.exit(0); ); frm.getContentPane().add(ex3_10); frm.setSize(300,400); frm.setVisible(true); ex14_3.html 〈HTMI〉 〈HEAD〉 〈TITLE〉ex14_3 〈/HEAD〉 〈BODY〉 〈applet code="ex14_3.class"width=800 height=400〉 〈/applet〉 〈/BODY〉 〈/HTML〉
进入题库练习
问答题基本操作题 下列程序中,要求建立一个包含一个方法的类,这个方法实现数组的拷贝,要求首先用直接初始化原始数组,然后将原始数组中的数据拷贝到目的数组,并分别输出原始数组和目的数组。要求数组类型为String类型,大小为4,采用动态分配的方式对数组进行初始化。请将程序补充完整。 程序运行结果如下: 原始的: 小龙 小张 小李 小陈 复制后的: 小龙 小张 小李 小陈 public class ex5_1 { public static void main(String[] args) { ex5_1 obj5_1=new ex5_1(); obj5_1. ; } public void method5_1(){ int i=0; String strMember[] = new String[4]; String strTemp[] = new String [4]; strMember[0] = "小龙"; strMember[1] = "小张"; strMember[2] = "小李"; strMember[3] = "小陈"; for(i=0; i<4; i++){ ; } System.out.println ("原始的:"); for(i=0; i<4; i++){ System.out.println ( ); } System.out.println ("复制后的:"); for(i=0; i<4; i++){ System.out.println (strTemp[i]); } } }
进入题库练习
问答题下面的程序是用do__while语句计算10的阶乘。请在程序的每条横线处填写一个语句,使程序的功能完整。 注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。 public class DoWhileLoop{ public static void main(_____________){ int n=10; long result=1; do { __________________ } __________________ System. out.println( "10的阶乘为: "+result); } }
进入题库练习
问答题下列程序要求将source.txt文件中的字符,通过文件输入/输出流复制到另一个dest.txt文件中。请将程序补充完整。 注意:不改动程序结构,不得增行或删行。 import java.io.*; public class ex2 public static void main(String[] args) throws IOException File inputFile; File outputFile; FileInputStream in; FileOutputStream out; int c; inputFile=new File("source.txt"); outputFile=new File("dest.txt"); in=new FileInputStream(inputFile); ______(outputFile); while((c=in.read())!=-1) ______; in.close(); out.close();
进入题库练习
问答题对上题再进行改进,使输入文件名和读文件内容的两类异常都能处理。请在横线处填上适当的子句,使其能捕获异常并正确执行。 import java.io.*; public class BException{ public static void main(String[]args){ //获得文件名 BufferedReader stdin=new BufferedReader(new InputStreamReader(System.in)); System.out.print("Filename:"); String s=null; try{ s=stdin.readLine(); }catch(OIException e){ System.err.println("Cannot read input"); System.exit(0); } BufferedReader filein=null; //为处理组织文件流 try{ Filein=new BufferedReader(new FileReader(s)); } catch(FileNotFoundException e){ System.err.println(s+":cannot be opened for reading"); System.exit(0); } try{ int numerator=Integer.parseInt(filein.readLine()); //提取值和计算商 int denominator=Integer.parseInt(filein.readLine()); int quotient=numerator/denominator; System.out.println(); System.out.println(numerator+"/"+denominator+"="+quotient); }______{ System.err.println(s+":unable to read values"); System.exit(0); } return; } }
进入题库练习
问答题请完成下列Java程序:输入2个整数,求最大公约数。要求有2个单行文本区作为输入,2个按钮,一个单击完成计算,一个单击退出程序。 注意:请勿改动main()主方法和其他已有语句内容,仅在下划线处填入适当的语句。 源程序文件代码清单如下: import java.awt.*; import java.awt.event.*; public class ex7_2 extends Frame implements ActionListener { private Label 1; private TextField tf,tf2; public static void main(String args[]) { ex7_2 obj7_2=new ex7_2(); } public ex7_2() { setTitle("ex7_2"); Panel p1; Button b=new Button("OK"); p1=new Panel(); tf=new TextField(8); p1.add(tf); tf2=new TextField(8); p1.add(tf2); b.addActionListener(this); p1.add(b); b=new Button("Exit"); b.addActionListener(this); p1.add(b); add("North",p1); Panel p2=new Panel(); l=new Label("最大公因数:"); p2.add(l); add("Center",p2); setsize(500,300); show(); } public void actionPerformed(ActionEvent ae) { if(ae.getActionCommand().equals("Exit")) //比较ae对象的标识名,是否为Exit System.exit(0); else if(ae.getActlonCommand().equals("OK")) { try { int a=Integer.parseInt(tf.getText()); int b=Integer.parseInt(tf2.getText()); int r,i; while(b>0){ ______; ______; b=r; } l.setText("最大公约数: "+Integer.toString(a)); }catch{NumberFormatException nfe) { l.setText("请正确输入!"); } } } }
进入题库练习
问答题下面是一个Applet程序,其功能是输出已定义好的两个变量x和chr。请改正程序中的错误(有下划线的语句),使用序能输出正确的结果。注意:不改动程序的结构,不得增行或删行。程序运行结果如下:importjava.awt.*;importjava.Applet;/*<appletCode="ex34_3.class"width=800height=400></applet>*/publicclassex34_3implementsAppletintx=10;charchr='R';Labeloutput1;Labeloutput2;privatevoidinit()output1=newLabel("定义int类型变量"+"x,的初值为"+x);output2=newLabel("定义char类型变量"+"chr,的初值为"+chr);add(output1);add(output2);ex34_3.html<HTML><HEAD><TITLE>ex34_3</TITLE></HEAD><BODY><appletcode="ex34_3.class"width=400height=400></applet></BODY></HTML>
进入题库练习
问答题下列Application程序输入一个整数,求出它的所有因子,请根据注释,将程序补充完整。 public class test19_2 public static void main(String args[])throws IOException int n; //下面7行语句的作用是从键盘输入n的值 InputStreamReader ir; BufferedReader in; ir=new lnputStreamReader(System.in); in=new BufferedReader(ir); System.out.println("Input n is:"); String s=in.______;//读取1行字符 n=Integer.parseInt(s); //下面求n的所有因子 ______(int i=1;i if(n%i!=0) ______;//跳过打印语句回到循环起始 System.out.print(i+””); System.out.print(“/n”);
进入题库练习
问答题本程序中,主窗口有一个按钮“登录”,单击该按钮后显示一个标题为“Login”的对话框,对话框中有“用户名”和“密码”两个文本框,以及“确定”和“撤销”两个按钮,如果单击“确定”按钮后返回主窗口,并将输入的用户名和密码在后台打印出来,否则直接返回主窗口,如图所示。importjava.awt.*;importjavax.swing.*;importjava.awt.event.*;publicclassexam_50extendsJFrame{JButtonbutton=newJButton("登录");JPanelpanel=newJPanel(newFlowLayout());publicexam_50(){finalJFrameframe=this;this.getContentPane().add(panel,BorderLayout.SOUTH);panel.add(button);button.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){showLoginDialog(frame);}});this.setSize(300,200);this.setTitle("exam_50");this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.show();}voidshowLoginDialog(JFrameframe){JPanelp=newJPanel(newGridLayout(0,1));JTextFieldtfUserName=newJTextField();JPasswordFieldtfPassword=______;p.add(newJLabel("用户名:"));p.add(tfUserName);p.add(newJLabel("密码:"));p.add(tfPassword);if(JOptionPane.showConfirmDialog(frame,P,"Login",JOptionPane.OK_CANCEL_OPTION,JOptionPane.PLAIN_MESSAGE)==JOptionPane.OK_OPTION){System.out.println("用户名:"+tfUserName.getText());System.out.println("密码:"+newString(______));}}publicstaticvoidmain(String[]args){exam50frame=newexam_50();}}
进入题库练习